From d778c3cf1992c51bf394308a944961fc863fb4be Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 15 Oct 2019 14:03:41 +0200 Subject: Better Opengraph image type detection --- include/opengraph.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include/opengraph.php') diff --git a/include/opengraph.php b/include/opengraph.php index 2d72ffca1..5360468eb 100644 --- a/include/opengraph.php +++ b/include/opengraph.php @@ -21,8 +21,10 @@ $ogtitle = $item['title']; // find first image if exist - if(preg_match("/\[[zi]mg(=[0-9]+x[0-9]+)?\]([^\[]+)/is", $item['body'], $matches)) + if(preg_match("/\[[zi]mg(=[0-9]+x[0-9]+)?\]([^\[]+)/is", $item['body'], $matches)) { $ogimage = $matches[2]; + $ogimagetype = guess_image_type($ogimage); + } // use summary as description if exist $ogdesc = (empty($item['summary']) ? $item['body'] : $item['summary'] ); @@ -57,12 +59,14 @@ } } - if(! isset($ogimage)) + if(! isset($ogimage)) { $ogimage = $channel['xchan_photo_l']; + $ogimagetype = $channel['xchan_photo_mimetype']; + } App::$page['htmlhead'] .= '' . "\r\n"; App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; App::$page['htmlhead'] .= '' . "\r\n"; App::$page['htmlhead'] .= '' . "\r\n"; -- cgit v1.2.3