forked from GNUsocial/gnu-social
$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:
parent
e6f07d8554
commit
80f7a5f025
@ -73,18 +73,20 @@ class OembedPlugin extends Plugin
|
|||||||
$metadata = OpenGraphHelper::ogFromHtml($dom);
|
$metadata = OpenGraphHelper::ogFromHtml($dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sometimes sites serve the path, not the full URL, for images
|
if (isset($metadata->thumbnail_url)) {
|
||||||
// let's "be liberal in what you accept from others"!
|
// sometimes sites serve the path, not the full URL, for images
|
||||||
// add protocol and host if the thumbnail_url starts with /
|
// let's "be liberal in what you accept from others"!
|
||||||
if(substr($metadata->thumbnail_url,0,1) == '/') {
|
// add protocol and host if the thumbnail_url starts with /
|
||||||
$thumbnail_url_parsed = parse_url($metadata->url);
|
if(substr($metadata->thumbnail_url,0,1) == '/') {
|
||||||
$metadata->thumbnail_url = $thumbnail_url_parsed['scheme']."://".$thumbnail_url_parsed['host'].$metadata->thumbnail_url;
|
$thumbnail_url_parsed = parse_url($metadata->url);
|
||||||
}
|
$metadata->thumbnail_url = $thumbnail_url_parsed['scheme']."://".$thumbnail_url_parsed['host'].$metadata->thumbnail_url;
|
||||||
|
}
|
||||||
|
|
||||||
// some wordpress opengraph implementations sometimes return a white blank image
|
// some wordpress opengraph implementations sometimes return a white blank image
|
||||||
// no need for us to save that!
|
// no need for us to save that!
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user