]> git.mxchange.org Git - friendica.git/commitdiff
Picture posts do work again - everything else should work as well
authorMichael <heluecht@pirati.ca>
Thu, 6 Sep 2018 20:30:16 +0000 (20:30 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 6 Sep 2018 20:30:16 +0000 (20:30 +0000)
src/Content/Text/BBCode.php
src/Util/ParseUrl.php

index 3054170fc05065fd0c17c1e7cc36843c6a0d3129..2dc13ae5e0241bc5121dbd024d4ff07ae92f79bc 100644 (file)
@@ -572,17 +572,17 @@ class BBCode extends BaseObject
                                        $return = sprintf('<div class="type-%s">', $data["type"]);
                                }
 
-                               if (!empty($data["image"])) {
-                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
-                               } elseif (!empty($data["preview"])) {
-                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
-                               }
-
-                               // 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('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
-                               } elseif (!empty($data['title']) && !empty($data['url'])) {
-                                       $return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
+                               if (!empty($data['title']) && !empty($data['url'])) {
+                                       if (!empty($data["image"]) && empty($data["text"]) && ($data["type"] == "photo")) {
+                                               $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a>', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
+                                       } else {
+                                               if (!empty($data["image"])) {
+                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
+                                               } elseif (!empty($data["preview"])) {
+                                                       $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
+                                               }
+                                               $return .= sprintf('<h4><a href="%s">%s</a></h4>', $data['url'], $data['title']);
+                                       }
                                }
 
                                if (!empty($data["description"]) && $data["description"] != $data["title"]) {
index 520100b6d7c65f266f49ae2eb6ffb8473542c917..4443da75641cd2876d4fbdb3ed17aca21d5d31dc 100644 (file)
@@ -271,11 +271,9 @@ class ParseUrl
                                        $siteinfo['image'] = $meta_tag['content'];
                                        break;
                                case 'twitter:card':
-                                       // Convert Twitter types in our own
+                                       // Detect photo pages
                                        if ($meta_tag['content'] == 'summary_large_image') {
                                                $siteinfo['type'] = 'photo';
-                                       } else {
-                                               $siteinfo['type'] = $meta_tag['content'];
                                        }
                                        break;
                                case 'twitter:description':
@@ -334,6 +332,11 @@ class ParseUrl
                        }
                }
 
+               // Prevent to have a photo type without an image
+               if (empty($siteinfo['image']) && (siteinfo['type'] == 'photo')) {
+                       $siteinfo['type'] = 'link';
+               }
+
                if ((@$siteinfo['image'] == '') && !$no_guessing) {
                        $list = $xpath->query('//img[@src]');
                        foreach ($list as $node) {