aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-10-15 14:11:21 +0200
committerMax Kostikov <max@kostikov.co>2019-10-15 14:11:21 +0200
commitc888e33f0490606e96d7c929a99803f09482e8e3 (patch)
treea1e817b040fca09a5bd9162652ec285d9eda7fb2
parent8bf57c62268df6c1f5149552e5c9dd9ab4da65aa (diff)
parent1a56ecaa393f9cd307c0fc883b6f2d8a17a07718 (diff)
downloadvolse-hubzilla-c888e33f0490606e96d7c929a99803f09482e8e3.tar.gz
volse-hubzilla-c888e33f0490606e96d7c929a99803f09482e8e3.tar.bz2
volse-hubzilla-c888e33f0490606e96d7c929a99803f09482e8e3.zip
Merge branch 'dev' into 'dev'
Better Opengraph image type detection See merge request hubzilla/core!1756
-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..ba97d4f4f 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";