Page 1 of 1

Phoca Opengraph plugin - Issues with images when sharing on Facebook

Posted: 09 Aug 2024, 10:50
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!

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

Posted: 09 Aug 2024, 12:34
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!

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

Posted: 14 Aug 2024, 12:00
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;
	}