From 81454547076f242dfe2fc19ab86d659b28405eb2 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Tue, 6 Dec 2022 00:48:28 +0100 Subject: [PATCH] Revert "Merge branch 'develop' into new_image_presentation" This reverts commit 76f4ba7685dc3c722464d3b5f8be8e1b08fef05a, reversing changes made to 733543505be2345b1a763b4924413569193773cc. --- src/Model/Item.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 152543b916..634dbbd0ea 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -21,6 +21,8 @@ namespace Friendica\Model; +use DOMDocument; +use DOMXPath; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; @@ -3085,9 +3087,10 @@ class Item ]; Hook::callAll('prepare_body', $hook_data); // Remove old images - $hook_data['html'] = preg_replace('|(.*)|', '', $hook_data['html']); - $grid = self::make_image_grid($hook_data); - $s = $hook_data['html'] . $grid; +// $hook_data['html'] = preg_replace('|(.*)|', '', $hook_data['html']); +// $grid = self::make_image_grid($hook_data); +// $s = $hook_data['html'] . $grid; + $s = $hook_data['html']; unset($hook_data); if (!$attach) { @@ -3131,6 +3134,27 @@ class Item return $hook_data['html']; } + /** + * This function removes images at the very end of a post based on the assumption that this images are interpreted + * as attachments + * @param array $rendered_html + * @return array + */ + private function cutAttachedImages(array &$rendered_html) { + $doc = new DOMDocument(); + $doc->loadHTML($rendered_html); + + $xpathsearch = new DOMXPath($doc); + $nodes = $xpathsearch->query("*"); + + return $nodes; + } + + /** + * @param array $data + * @return string|void + * @throws \Friendica\Network\HTTPException\ServiceUnavailableException + */ private function make_image_grid(array &$data) { $item = $data['item']; @@ -3149,6 +3173,7 @@ class Item 'preview' => $preview_url, 'attachment' => $attachment, ]); + // @todo add some fany ai to divide images equally on both columns if ($count % 2 == 0) { $img_tags_fc[] = $img_tag; } else { -- 2.39.5