]> git.mxchange.org Git - friendica.git/commitdiff
Fix Twitter quote tweet display
authorHypolite Petovan <mrpetovan@gmail.com>
Sat, 6 Jan 2018 05:39:59 +0000 (00:39 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Sat, 6 Jan 2018 05:39:59 +0000 (00:39 -0500)
- Transforms twitter share tags into rich OEmbed attachments

include/bbcode.php

index 87a8eaa9b38d6518c57c779e0cf026d5567737bf..3e82f90a165d8347ddeaeeb0f76c7852229f2ee9 100644 (file)
@@ -76,7 +76,7 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
                        $oembed = $bookmark[0];
                }
 
-               if (strstr(strtolower($oembed), "<iframe ")) {
+               if (stripos($oembed, "<iframe ") !== false) {
                        $text = $oembed;
                } else {
                        if (($data["image"] != "") && !strstr(strtolower($oembed), "<img ")) {
@@ -541,7 +541,7 @@ function bb_ShareAttributes($share, $simplehtml)
                                $text .= "<hr />";
                        }
 
-                       if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") {
+                       if (stripos(normalise_link($link), 'http://twitter.com/') === 0) {
                                $text .= $headline . '<blockquote>' . trim($share[3]) . "</blockquote><br />";
 
                                if ($link != "") {
@@ -586,20 +586,26 @@ function bb_ShareAttributes($share, $simplehtml)
                        }
                        break;
                default:
-                       $text = trim($share[1]) . "\n";
-
-                       $avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB);
-
-                       $tpl = get_markup_template('shared_content.tpl');
-                       $text .= replace_macros($tpl, array(
-                                       '$profile' => $profile,
-                                       '$avatar' => $avatar,
-                                       '$author' => $author,
-                                       '$link' => $link,
-                                       '$posted' => $posted,
-                                       '$content' => trim($share[3])
-                               )
-                       );
+                       // Transforms quoted tweets in rich attachments to avoid nested tweetsx
+                       if (stripos(normalise_link($link), 'http://twitter.com/') === 0) {
+                               $bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $link, $preshare), $link, $preshare);
+                               $text = $preshare . tryoembed($bookmark);
+                       } else {
+                               $text = trim($share[1]) . "\n";
+
+                               $avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB);
+
+                               $tpl = get_markup_template('shared_content.tpl');
+                               $text .= replace_macros($tpl, array(
+                                               '$profile' => $profile,
+                                               '$avatar' => $avatar,
+                                               '$author' => $author,
+                                               '$link' => $link,
+                                               '$posted' => $posted,
+                                               '$content' => trim($share[3])
+                                       )
+                               );
+                       }
                        break;
        }