I manage to find a solution, but I would like a help to make it "pro" solution.
I'll post here the code I used to it, but it only will work if there is no image into the article, only in the "intro image".
Code: Select all
// Article Image
$article = JTable::getInstance("content");
$article->load(JRequest::getInt("id")); // Get Article ID
$article_images = $article->get("images"); // Get image parameters
$pictures = json_decode($article_images); // Split the parameters apart
// Print the image
//echo "<img src='" . $pictures->{'image_intro'} . "' alt='" . $pictures->{'image_intro_alt'} . "'>";
$document->setMetadata('og:image', $pictures->{'image_intro'});
I'll post now where is it being to work
Code: Select all
// Image
// Article Image
$article = JTable::getInstance("content");
$article->load(JRequest::getInt("id")); // Get Article ID
$article_images = $article->get("images"); // Get image parameters
$pictures = json_decode($article_images); // Split the parameters apart
// Print the image
//echo "<img src='" . $pictures->{'image_intro'} . "' alt='" . $pictures->{'image_intro_alt'} . "'>";
$document->setMetadata('og:image', $pictures->{'image_intro'});
if ($this->params->get('image'.$suffix, '') != '') {
$document->setMetadata('og:image', JURI::base(false).htmlspecialchars($this->params->get('image'.$suffix, '')));
} else {
// Try to find image in article
$img = 0;
$fulltext = '';
if (isset($row->fulltext) && $row->fulltext != '') {
$fulltext = $row->fulltext;
}
Jan, do you think we can get it to work better? I'm not that expert into PHP skills. Besides, OO kills me lol