From 04fb88585783f4883b40ec9d49a4a7fa644fb294 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 6 Sep 2018 04:24:34 +0000 Subject: [PATCH] Fix: Posts with pictures will now look good again on connector networks --- mod/photos.php | 2 +- src/Content/Text/BBCode.php | 5 ++++- src/Util/ParseUrl.php | 10 +++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index 5fb6ba368..16af45599 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1633,7 +1633,7 @@ function photos_content(App $a) '$paginate' => $paginate, ]); - $a->page['htmlhead'] .= "\n" . '' . "\n"; + $a->page['htmlhead'] .= "\n" . '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; $a->page['htmlhead'] .= '' . "\n"; diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 55fc24273..3054170fc 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -578,7 +578,10 @@ class BBCode extends BaseObject $return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); } - if (!empty($data['title']) && !empty($data['url'])) { + // Show a picture only when the BBCode is meant for posts to connector networks + if (($simplehtml != 0) && ($data["type"] == "photo") && !empty($data["url"]) && !empty($data["image"])) { + $return .= sprintf('', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); + } elseif (!empty($data['title']) && !empty($data['url'])) { $return .= sprintf('

%s

', $data['url'], $data['title']); } diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 2c134542a..520100b6d 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -271,9 +271,9 @@ class ParseUrl $siteinfo['image'] = $meta_tag['content']; break; case 'twitter:card': - // Obsolete card type - if ($meta_tag['content'] == 'photo') { - $siteinfo['type'] = 'summary_large_image'; + // Convert Twitter types in our own + if ($meta_tag['content'] == 'summary_large_image') { + $siteinfo['type'] = 'photo'; } else { $siteinfo['type'] = $meta_tag['content']; } @@ -299,10 +299,6 @@ class ParseUrl } } - if ($siteinfo['type'] == 'summary' || $siteinfo['type'] == 'summary_large_image') { - $siteinfo['type'] = 'link'; - } - if (isset($keywords)) { $siteinfo['keywords'] = []; foreach ($keywords as $keyword) {