• A new version of Full Calendar is now available.

    See the details here

Set meta image for detail view

aijosh

Member
Hello,

I was able to set the meta description for detail view

$pagegrp = $this->groups['Page'];
$elements = $pagegrp->elements;
$picture = $elements['picture']->element;
$details = $elements['details']->element;
$details = strip_tags($details);
$details = substr($details,0,500);

$mydoc = JFactory::getDocument();
$mydoc->setDescription($details);

I couldn't find how to set the default image.

How do I achieve this?
 
No idea, I don't even know what a "meta image" is.

There's a generic $doc->addMetaData($name, $content, $attribute) method, which internally will set $doc->_metaTags[$attribute][$name] = $content.

-- hugh
 
No idea, I don't even know what a "meta image" is.
I had to call it something.

Its usually the og:image displayed when sharing links via social media (WhatsApp, facebook e.t.c)

If no image is specified, I think the first high resolution image is selected by default (which is not always correct).

Its ok though.

Wanted to know if its possible as its a better option to set it explicitly.

Thanks
 
Oh, an Open Graph image ... OK ... in which case yes, you can set it with the method I referenced.

Code:
// following assumes you've set $imageURL and $imagePath appropriately
$document->setMetaData('og:image', $imageURL, 'property');
// you prolly need to tell people the width and height as well
list($width, $height) = getimagesize($imagePath);
$document->setMetaData('og:image:width', $width, 'property');
$document->setMetaData('og:image:height', $height, 'property');

-- hugh
 
Back
Top