Keyword

K2 homepage missing open graph image

More
11 years 7 months ago - 11 years 7 months ago #110861 by flo
Hi guys,

My websites homepage www.elitetravel.hr is somehow missing open graph image code. It is set to show k2 Categories display and no matter how i paste the homepage link on facebook it never shows thumbnail image, not single one. Strange thing but this happens only at the homepage. Each other item or categorie works like a charm.

Other subpages all have both...
<meta property="og:image" content="http://www.elitetravel.hr/media/k2/items/cache/93ba6c299f04f710c35672b0f157402a_S.jpg" />

and
<meta name="image" content="http://www.elitetravel.hr/media/k2/items/cache/93ba6c299f04f710c35672b0f157402a_S.jpg" />

i think this occured after the last update but i am not sure about that. I tried switching templates, that didn't work. I tried searching for og settings under k2, that didnt work either. I am clueless.

Thank you

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

More
11 years 7 months ago #110862 by flo
frustrating!

even when i add og:image or <link rel img src thing through index.php and it appears under view source it gives me same results. no facebook link image at all. this is so stupid.

could someone inspect this issue. thank you

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

More
11 years 7 months ago #110863 by flo
update

after few hours of fighting with different variations i think i figured out the problem. my homepage is set to show multiple k2 categories which all have their own pictures. so, my homepage grabs com_k2/views/temlist/view.html.php file which has this og:image set-up:
if ($task == 'category' && $this->category->image && strpos($this->category->image, 'placeholder/category.png') === false)
		{
			$image = substr(JURI::root(), 0, -1).str_replace(JURI::root(true), '', $this->category->image);
			$document->setMetaData('og:image', $image);
			$document->setMetaData('image', $image);
		}

As far as i understood, it tries to grab category image. But what happens if there are multiple categories inside? In my case it grabs nothing and when i publish my website link on facebook it gives me no image link.

What i did, as temporary solution, after this i added
$document->setMetaData('og:image', 'http://www.elitetravel.hr/images/images/fb_logo.jpg');

I debugged the links through developers.facebook.com/tools/debug refreshed the page, purged cache and suddenly image is working again. When i post my full website url on facebook it gives me fb_logo.jpg as stated above.

Downside of this is that now all my categories don't show their category image, instead they show this one.

So my code now looks like this
// Set Facebook meta data
		$document = JFactory::getDocument();
		$uri = JURI::getInstance();
		$document->setMetaData('og:url', $uri->toString());
		$document->setMetaData('og:title', htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8'));
		$document->setMetaData('og:type', 'Article');
		if ($task == 'category' && $this->category->image && strpos($this->category->image, 'placeholder/category.png') === false)
		{
			$image = substr(JURI::root(), 0, -1).str_replace(JURI::root(true), '', $this->category->image);
			$document->setMetaData('og:image', $image);
			$document->setMetaData('image', $image);
		}
		$document->setMetaData('og:description', htmlspecialchars(strip_tags($document->getDescription()), ENT_QUOTES, 'UTF-8'));
		$document->setMetaData('og:image', 'http://www.elitetravel.hr/images/images/fb_logo.jpg');

To sum up, good thing i figured out how to revive the link again. Now to figure out how to do this ONLY for homepage.

If you have some time to read this through and help me i would really appreciate it. I will keep this topic alive.

Many thanks

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

More
11 years 6 months ago #110864 by flo
After few days of testing it seems to be ok now, altought i would like someone to check this out for me (us) anyway :)

Will try to keep this topic alive :)

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


Powered by Kunena Forum