1
votes

I am the administrator of a Joomla 1.5 site. I encountered a problem today, because when I was sharing an article on Facebook, it was being displayed without image. Searching the internet, I found that Facebook needs a link tag to be in the header of the html page, like this:

<link rel="image_src" href="..." />

while my site provides something like this

<meta name="image" content="...." />

My website is using the K2 plugin for articles I have very limited knowledge of Joomla as I have never worked with it, but tried to search the structure of the files and found that in the item.php file the image was referenced like this:

$this->item->image

So I modified the index.php file of the main template to add the following tag in the header:

<link rel="image_src" href="<?php echo JURI::base() . $this->item->image; ?>" />

However, although the $this->item->image; does not give any error it returns nothing. Am I doing something wrong?

Thank you in advance

1

1 Answers

0
votes

$this refers to the context of the plugin, while in the template $this is the template, thus the error.

I haven't worked with 1.5 in a long time, but consider that a system plugin has access to the generated markup; so it could insert any tags manipulating the html text.

However it would need access to the component's data in order to get the image. But the component runs before the plugin, so you could set a post var or a global in the component:

JRequest::setVar('templateheader',$this->item->image);

then retrieve it in the system plugin or libraries/joomla/document/html/renderer/head.php (core hack) and print it out.