Skip to content

Commit

Permalink
Fixed image field and toolbar field to insert absolute image URLs, an…
Browse files Browse the repository at this point in the history
…d also added og:url to toolbar field as this is required by facebook during share this page preview in popup window
  • Loading branch information
ggppdk committed Aug 31, 2015
1 parent 50394bf commit bde9918
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
12 changes: 6 additions & 6 deletions plugins/flexicontent_fields/image/image.php
Expand Up @@ -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('<link rel="image_src" href="'.$ogp_src.'" />');
$document->addCustomTag('<meta property="og:image" content="'.$ogp_src.'" />');
Expand Down
17 changes: 14 additions & 3 deletions plugins/flexicontent_fields/toolbar/toolbar.php
Expand Up @@ -269,8 +269,19 @@ function changetextsize(up){
{
$imageurl = $this->_extractimageurl($item);
}
if ($imageurl) $document->addCustomTag("<meta property=\"og:image\" content=\"{$imageurl}\" />");
// 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("<meta property=\"og:image\" content=\"{$imageurl}\" />");
}
}

// Add og-URL explicitely as this is required by facebook ?
if ($item_link) {
$document->addCustomTag("<meta property=\"og:url\" content=\"".$item_link."\" />");
}



// ****************************
Expand Down Expand Up @@ -384,12 +395,12 @@ function changetextsize(up){

if (!$addthis) {
$document->addCustomTag('
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid='.$addthis_pubid.'"></script>
<script type="text/javascript">
var addthis_config = {
services_exclude: "print,email"
services_exclude: "print,email"
}
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js'.($addthis_pubid ? '#pubid='.$addthis_pubid : '').'"></script>
');
$addthis = 1;
}
Expand Down

0 comments on commit bde9918

Please sign in to comment.