From 5b5e5ef4db5e502346c36428156aee1b707db5c0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 13 Sep 2018 21:50:52 -0400 Subject: [PATCH 1/2] Use OEmbed data when available no matter the type --- src/Util/ParseUrl.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 40cb0b8fc0..5745c65595 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -161,16 +161,14 @@ class ParseUrl $siteinfo['type'] = $oembed_data->type; } - if (($oembed_data->type == 'link') && ($siteinfo['type'] != 'photo')) { - if (isset($oembed_data->title)) { - $siteinfo['title'] = trim($oembed_data->title); - } - if (isset($oembed_data->description)) { - $siteinfo['text'] = trim($oembed_data->description); - } - if (isset($oembed_data->thumbnail_url)) { - $siteinfo['image'] = $oembed_data->thumbnail_url; - } + if (isset($oembed_data->title)) { + $siteinfo['title'] = trim($oembed_data->title); + } + if (isset($oembed_data->description)) { + $siteinfo['text'] = trim($oembed_data->description); + } + if (isset($oembed_data->thumbnail_url)) { + $siteinfo['image'] = $oembed_data->thumbnail_url; } } } @@ -337,7 +335,7 @@ class ParseUrl $siteinfo['type'] = 'link'; } - if ((@$siteinfo['image'] == '') && !$no_guessing) { + if (empty($siteinfo['image']) && !$no_guessing) { $list = $xpath->query('//img[@src]'); foreach ($list as $node) { $img_tag = []; From 102adf86aef133afb4afe501bbe0bbab0bb1a56a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 16 Sep 2018 09:18:31 -0400 Subject: [PATCH 2/2] Restore partial condition in OEmbed block of ParseUrl::getSiteInfo --- src/Util/ParseUrl.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 5745c65595..8c8914534e 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -161,14 +161,17 @@ class ParseUrl $siteinfo['type'] = $oembed_data->type; } - if (isset($oembed_data->title)) { - $siteinfo['title'] = trim($oembed_data->title); - } - if (isset($oembed_data->description)) { - $siteinfo['text'] = trim($oembed_data->description); - } - if (isset($oembed_data->thumbnail_url)) { - $siteinfo['image'] = $oembed_data->thumbnail_url; + // See https://github.com/friendica/friendica/pull/5763#discussion_r217913178 + if ($siteinfo['type'] != 'photo') { + if (isset($oembed_data->title)) { + $siteinfo['title'] = trim($oembed_data->title); + } + if (isset($oembed_data->description)) { + $siteinfo['text'] = trim($oembed_data->description); + } + if (isset($oembed_data->thumbnail_url)) { + $siteinfo['image'] = $oembed_data->thumbnail_url; + } } } }