diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index ec8497e8c..73838997c 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -73,6 +73,7 @@ class Context * @var array */ public $meta_tags = array(); + public $meta_images = array(); /** * OpenGraph metadata @@ -2631,6 +2632,42 @@ class Context self::$_instance->meta_tags[$name] = array('is_http_equiv' => (bool)$is_http_equiv, 'content' => $content); } + /** + * Get meta images + * + * @return array + */ + public static function getMetaImages() + { + return self::$_instance->meta_images; + } + + /** + * Add meta image + * + * @param string $filename + * @param int $width + * @param int $height + * @return void + */ + public static function addMetaImage($filename, $width = 0, $height = 0) + { + $filename = preg_replace('/^[.\\\\\\/]+/', '', $filename); + if (!file_exists(\RX_BASEDIR . $filename)) + { + return; + } + if ($width == 0 || $height == 0) + { + list($width, $height) = getimagesize(\RX_BASEDIR . $filename); + } + self::$_instance->meta_images[] = array( + 'filepath' => $filename . '?' . date('YmdHis', filemtime(\RX_BASEDIR . $filename)), + 'width' => $width, + 'height' => $height, + ); + } + /** * Get OpenGraph metadata * diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index 30847da5d..fdd9544ea 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -500,7 +500,11 @@ class HTMLDisplayHandler } // Add image. - if ($page_type === 'article' && $permitted && config('seo.og_extract_images')) + if ($document_images = Context::getMetaImages()) + { + // pass + } + elseif ($page_type === 'article' && $permitted && config('seo.og_extract_images')) { if (($document_images = Rhymix\Framework\Cache::get("seo:document_images:$document_srl")) === null) {