$metadata->thumbnail_url is not guaranteed to be set

We should probably have a separate class for this, so we can more
easily combine different technologies similar to oEmbed/OpenGraph.
This commit is contained in:
Mikael Nordfeldth 2016-02-25 19:46:17 +01:00
parent e6f07d8554
commit 80f7a5f025

View File

@ -73,6 +73,7 @@ class OembedPlugin extends Plugin
$metadata = OpenGraphHelper::ogFromHtml($dom); $metadata = OpenGraphHelper::ogFromHtml($dom);
} }
if (isset($metadata->thumbnail_url)) {
// sometimes sites serve the path, not the full URL, for images // sometimes sites serve the path, not the full URL, for images
// let's "be liberal in what you accept from others"! // let's "be liberal in what you accept from others"!
// add protocol and host if the thumbnail_url starts with / // add protocol and host if the thumbnail_url starts with /
@ -86,6 +87,7 @@ class OembedPlugin extends Plugin
if($metadata->thumbnail_url == 'https://s0.wp.com/i/blank.jpg') { if($metadata->thumbnail_url == 'https://s0.wp.com/i/blank.jpg') {
unset($metadata->thumbnail_url); unset($metadata->thumbnail_url);
} }
}
} }