aboutsummaryrefslogtreecommitdiffstats
path: root/include/opengraph.php
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-10-15 14:03:41 +0200
committerMax Kostikov <max@kostikov.co>2019-10-15 14:03:41 +0200
commitd778c3cf1992c51bf394308a944961fc863fb4be (patch)
tree81d7f9d01350e5a34fb3620deb75b8ef83059939 /include/opengraph.php
parent3c762b88093fbacf2b5e8c64f698ac09bed898af (diff)
downloadvolse-hubzilla-d778c3cf1992c51bf394308a944961fc863fb4be.tar.gz
volse-hubzilla-d778c3cf1992c51bf394308a944961fc863fb4be.tar.bz2
volse-hubzilla-d778c3cf1992c51bf394308a944961fc863fb4be.zip
Better Opengraph image type detection
Diffstat (limited to 'include/opengraph.php')
-rw-r--r--include/opengraph.php10
1 files changed, 7 insertions, 3 deletions
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'] .= '<meta property="og:title" content="' . htmlspecialchars((isset($ogtitle) ? $ogtitle : $channel['channel_name'])) . '">' . "\r\n";
App::$page['htmlhead'] .= '<meta property="og:image" content="' . $ogimage . '">' . "\r\n";
- App::$page['htmlhead'] .= '<meta property="og:image:type" content="' . guess_image_type($ogimage) . '">' . "\r\n";
+ App::$page['htmlhead'] .= '<meta property="og:image:type" content="' . $ogimagetype . '">' . "\r\n";
App::$page['htmlhead'] .= '<meta property="og:description" content="' . htmlspecialchars($ogdesc) . '">' . "\r\n";
App::$page['htmlhead'] .= '<meta property="og:type" content="' . (isset($ogtype) ? $ogtype : "profile") . '">' . "\r\n";