Phoca Opengraph plugin - Issues with images when sharing on Facebook

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
isidrobaq
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 03 May 2019, 11:07

Phoca Opengraph plugin - Issues with images when sharing on Facebook

Post by isidrobaq »

Hi

The issue in short: when sharing a post in Facebook, it seems that Facebook itself has some issues with image urls generated by Joomla, as they add something like

#joomlaImage://local-images/imagename.jpg

after the "normal" path for the article image.

I've been searching and reading stuff to try to figure out a solution, to no avail. Is there any known solution for this issue? In case no, would it be possible to filter image urls retrieved from Joomla intro/full images and remove the hash and everything after it from the plugin code?

Thanks in advance!
isidrobaq
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 03 May 2019, 11:07

Re: Phoca Opengraph plugin - Issues with images when sharing on Facebook

Post by isidrobaq »

Ok, I implemented a workaround that gets this fixed for me, just in case someone else finds it useful: just add the following code at line 87 in plugins/content/phocaopengraph/phocaopengraph.php

Code: Select all

      	if (strpos($linkImg, '#') !== false){
            $hashpos = strpos($linkImg, '#');
            $linkImg = substr($linkImg, 0, $hashpos);
        }
This way, if the image URL contains a hash character, it and everything after it will be removed from the url that will be used in the og:image parameter.

Would be nice if this could be added as an option in the plugin settings :).

Cheers!
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48303
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Opengraph plugin - Issues with images when sharing on Facebook

Post by Jan »

Hi, which version of Phoca Open Graph plugin do you use?

Phoca Open Graph uses the clean function for images:

Code: Select all

// https://github.com/joomla/joomla-cms/issues/35871
	function realCleanImageUrl($img) {

		$imgClean = HTMLHelper::cleanImageURL($img);
		if ($imgClean->url != '') {
			$img =  $imgClean->url;
		}
		return $img;
	}
If you find Phoca extensions useful, please support the project
Post Reply