From bde9918dd9efd33ed490805a8b3971a9c092ddf7 Mon Sep 17 00:00:00 2001 From: ggppdk Date: Tue, 1 Sep 2015 01:42:05 +0300 Subject: [PATCH] Fixed image field and toolbar field to insert absolute image URLs, and also added og:url to toolbar field as this is required by facebook during share this page preview in popup window --- plugins/flexicontent_fields/image/image.php | 12 ++++++------ plugins/flexicontent_fields/toolbar/toolbar.php | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/plugins/flexicontent_fields/image/image.php b/plugins/flexicontent_fields/image/image.php index 13d961a5788..7c2b94fac41 100644 --- a/plugins/flexicontent_fields/image/image.php +++ b/plugins/flexicontent_fields/image/image.php @@ -1488,16 +1488,16 @@ function onDisplayFieldValue(&$field, $item, $values=null, $prop='display') $field->thumbs_path['large'][] = JPATH_SITE.DS.$srcl; $field->thumbs_path['original'][] = JPATH_SITE.DS.$srco; - // Suggest image for external use, e.g. for Facebook etc + // Suggest image for external use, e.g. for Facebook etc, (making sure that URL is ABSOLUTE URL) if ( ($isSite && !$isFeedView) && $useogp ) { if ( in_array($view, $ogpinview) ) { switch ($ogpthumbsize) { - case 1: $ogp_src = $field->thumbs_src['small'][$i]; break; // this maybe problematic, since it maybe too small or not accepted by social website - case 2: $ogp_src = $field->thumbs_src['medium'][$i]; break; - case 3: $ogp_src = $field->thumbs_src['large'][$i]; break; - case 4: $ogp_src = $field->thumbs_src['original'][$i]; break; - default: $ogp_src = $field->thumbs_src['medium'][$i]; break; + case 1: $ogp_src = JURI::root().$srcs; break; // this maybe problematic, since it maybe too small or not accepted by social website + case 2: $ogp_src = JURI::root().$srcm; break; + case 3: $ogp_src = JURI::root().$srcl; break; + case 4: $ogp_src = JURI::root().$srco; break; + default: $ogp_src = JURI::root().$srcm; break; } $document->addCustomTag(''); $document->addCustomTag(''); diff --git a/plugins/flexicontent_fields/toolbar/toolbar.php b/plugins/flexicontent_fields/toolbar/toolbar.php index 47cc0af5e86..13a75a1bf87 100644 --- a/plugins/flexicontent_fields/toolbar/toolbar.php +++ b/plugins/flexicontent_fields/toolbar/toolbar.php @@ -269,8 +269,19 @@ function changetextsize(up){ { $imageurl = $this->_extractimageurl($item); } - if ($imageurl) $document->addCustomTag(""); + // Add image if fould, making sure it is converted to ABSOLUTE URL + if ($imageurl) { + $is_absolute = (boolean) parse_url($imageurl, PHP_URL_SCHEME); // preg_match("#^http|^https|^ftp#i", $imageurl); + $imageurl = $is_absolute ? $imageurl : JURI::root().$imageurl; + $document->addCustomTag(""); + } + } + + // Add og-URL explicitely as this is required by facebook ? + if ($item_link) { + $document->addCustomTag(""); } + // **************************** @@ -384,12 +395,12 @@ function changetextsize(up){ if (!$addthis) { $document->addCustomTag(' - + '); $addthis = 1; }