mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Merge pull request #2902 from Serios/patch-10
og:image setting if there is no already set one
This commit is contained in:
@@ -26,7 +26,42 @@ class social_event
|
|||||||
|
|
||||||
function config()
|
function config()
|
||||||
{
|
{
|
||||||
|
$event = array();
|
||||||
|
|
||||||
|
$event[] = array(
|
||||||
|
'name' => "system_meta_pre",
|
||||||
|
'function' => "ogg_image_add",
|
||||||
|
);
|
||||||
|
|
||||||
|
return $event;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function to add og:image if there is no any
|
||||||
|
*/
|
||||||
|
function ogg_image_add()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($ogImage) && !$ogimgexist) {
|
||||||
|
e107::meta('og:image',e107::getParser()->thumbUrl($ogImage,'w=500',false,true));
|
||||||
|
unset($ogImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user