Keyword

Og:image Width and Height

  • mjmartino
  • mjmartino's Avatar Topic Author
  • Offline
  • New Member
More
3 weeks 5 hours ago #173661 by mjmartino
mjmartino created the topic: Og:image Width and Height
Hi Fortis
Could you add in new version meta tag og:image
Meta Tag <meta property="og:image:width" content="1200" />
Meta Tag <meta property="og:image:height" content="600" />
If facebook not found this tag og:image with width and height image is not grab the first time. The workaround is to add the link a second time, then FB downloads the image, but it is annoying.

Regards :)

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Online
  • Administrator
  • JoomlaWorks Support Team
More
3 weeks 37 minutes ago #173668 by Fotis
Fotis replied the topic: Og:image Width and Height
I'm not aware of such an issue (and we deal with large news sites daily - so I'd know for sure).

Plus, to add automatic width/height values means PHP would work to read an image's dimensions using GD, which is wasted CPU resources really...

In any case, it's easy for you to override any K2 meta tag directly from your K2 template overrides. Inside your item.php override, add this at the top of the file (after <?php):
<?php

// no direct access
defined('_JEXEC') or die;

// Get the image and its dimensions
if($this->item->params->get('itemImage') && !empty($this->item->image) {

    $basename = basename($this->item->image);
    if (strpos($basename, '?t=')!==false) {
        $tmpBasename = explode('?t=', $basename);
        $basenameWithNoTimestamp = $tmpBasename[0];
    } else {
        $basenameWithNoTimestamp = $basename;
    }

    $imagePathOnSystem = JPATH_SITE.'/media/k2/items/cache/'.$basenameWithNoTimestamp;

    if (JFile::exists($imagePathOnSystem)) {
        list($width, $height) = getimagesize($imagePathOnSystem);

        $document = JFactory::getDocument();
        $document->setMetaData('og:image:width', $width);
        $document->setMetaData('og:image:height', $height);
    }
}

Easy-peasy with K2 :)

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.

  • mjmartino
  • mjmartino's Avatar Topic Author
  • Offline
  • New Member
More
2 weeks 6 days ago #173684 by mjmartino
mjmartino replied the topic: Og:image Width and Height
Thank for quick answer and solution.
I will test it.

Please Log in or Create an account to join the conversation.

  • mjmartino
  • mjmartino's Avatar Topic Author
  • Offline
  • New Member
More
2 weeks 5 days ago - 2 weeks 5 days ago #173702 by mjmartino
mjmartino replied the topic: Og:image Width and Height
I don't whre is error find but
syntax error, unexpected '{'
Last edit: 2 weeks 5 days ago by mjmartino.

Please Log in or Create an account to join the conversation.

  • Fotis
  • Fotis's Avatar
  • Online
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 5 days ago #173709 by Fotis
Fotis replied the topic: Og:image Width and Height
Change to:
<?php

// no direct access
defined('_JEXEC') or die;

// Get the image and its dimensions
if($this->item->params->get('itemImage') && !empty($this->item->image)) {

    $basename = basename($this->item->image);
    if (strpos($basename, '?t=')!==false) {
        $tmpBasename = explode('?t=', $basename);
        $basenameWithNoTimestamp = $tmpBasename[0];
    } else {
        $basenameWithNoTimestamp = $basename;
    }

    $imagePathOnSystem = JPATH_SITE.'/media/k2/items/cache/'.$basenameWithNoTimestamp;

    if (JFile::exists($imagePathOnSystem)) {
        list($width, $height) = getimagesize($imagePathOnSystem);

        $document = JFactory::getDocument();
        $document->setMetaData('og:image:width', $width);
        $document->setMetaData('og:image:height', $height);
    }
}

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum