• Payment Plugins Poll

    We need your feedback on the need for updated payment plugins. Please go here and give us your feedback.

  • Joomla 5.1

    For running J!5.1 you must install Fabrik 4.1
    See also Announcements

  • Subscription and download (Fabrik 4.1 for J!4.2+ and J!5.1) are working now

    See Announcement
    Please post subscription questions and issues here

    We have resolved the issue with the J! updater and this will be fixed in the next release.

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