diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 02de97f3d..88369711a 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -4307,7 +4307,7 @@ class eResponse { $attrData = ''; - e107::getEvent()->trigger('system_meta_pre'); + e107::getEvent()->trigger('system_meta_pre', $this->_meta); foreach ($this->_meta as $attr) { diff --git a/e107_plugins/social/e_event.php b/e107_plugins/social/e_event.php index 2a82db02d..809e44b06 100644 --- a/e107_plugins/social/e_event.php +++ b/e107_plugins/social/e_event.php @@ -30,41 +30,41 @@ class social_event $event[] = array( 'name' => "system_meta_pre", - 'function' => "ogg_image_add", + 'function' => "og_image_add", ); return $event; } - + + + /** * Callback function to add og:image if there is no any */ - function ogg_image_add() + function og_image_add($meta) { - $ogImage = e107::pref('social','og_image', false); - - if(e_ADMIN_AREA !==true) { - $ogimgexist = FALSE; - - // check if we have og:image defined - $response = e107::getSingleton('eResponse'); - $data = $response->getMeta(); - foreach($data as $m) { - if($m['name'] == 'og:image') { - $ogimgexist = TRUE; - } + $ogImage = e107::pref('social', 'og_image', false); + + if(empty($ogImage) || empty($meta) || e_ADMIN_AREA === true) + { + return null; + } + + // check if we have og:image defined + foreach($meta as $m) + { + if($m['name'] === 'og:image') + { + return null; } - - if(!empty($ogImage) && !$ogimgexist) { - e107::meta('og:image',e107::getParser()->thumbUrl($ogImage,'w=500',false,true)); - unset($ogImage); - } - - } - + } + + e107::meta('og:image', e107::getParser()->thumbUrl($ogImage, 'w=500', false, true)); + } } //end class -?> + +