From b88c9f9d6769ebdb841e5ba11f7a48c85f848b51 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 29 Apr 2021 19:29:29 +0000 Subject: [PATCH] Handling bottom anchor and top anchor --- src/Content/Text/BBCode.php | 5 +++-- src/Model/Item.php | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 44ef6e7f1b..48fda6296c 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -61,7 +61,8 @@ class BBCode const BACKLINK = 8; const ACTIVITYPUB = 9; - const ANCHOR = '
'; + const TOP_ANCHOR = '
'; + const BOTTOM_ANCHOR = '
'; /** * Fetches attachment data that were generated the old way * @@ -1089,7 +1090,7 @@ class BBCode '$guid' => $attributes['guid'], '$network_name' => ContactSelector::networkToName($network, $attributes['profile']), '$network_icon' => ContactSelector::networkToIcon($network, $attributes['profile']), - '$content' => self::setMentions(trim($content), 0, $network) . self::ANCHOR, + '$content' => self::TOP_ANCHOR . self::setMentions(trim($content), 0, $network) . self::BOTTOM_ANCHOR, ]); break; } diff --git a/src/Model/Item.php b/src/Model/Item.php index 3516a57bde..9fa657a69f 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2799,13 +2799,18 @@ class Item 'attachment' => $attachment, ], ]); - $trailing .= $media; + // On Diaspora posts the attached pictures are leading + if ($item['network'] == Protocol::DIASPORA) { + $leading .= $media; + } else { + $trailing .= $media; + } } } if ($shared) { - $content = str_replace(BBCode::ANCHOR, '
' . $leading . '
' . BBCode::ANCHOR, $content); - $content = str_replace(BBCode::ANCHOR, BBCode::ANCHOR . '
' . $trailing . '
', $content); + $content = str_replace(BBCode::TOP_ANCHOR, '
' . $leading . '
' . BBCode::TOP_ANCHOR, $content); + $content = str_replace(BBCode::BOTTOM_ANCHOR, '
' . $trailing . '
' . BBCode::BOTTOM_ANCHOR, $content); } else { if ($leading != '') { $content = '
' . $leading . '
' . $content; @@ -2881,7 +2886,7 @@ class Item // @todo Use a template $rendered = BBCode::convertAttachment('', BBCode::INTERNAL, false, $data); if ($shared) { - return str_replace(BBCode::ANCHOR, BBCode::ANCHOR . $rendered, $content); + return str_replace(BBCode::BOTTOM_ANCHOR, BBCode::BOTTOM_ANCHOR . $rendered, $content); } else { return $content . $rendered; }