From 49dab14215c854b8bae55be4459842a93f8e4b3c Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 21 May 2022 06:58:26 +0000 Subject: [PATCH] Only use proxied image links with images --- src/Model/Item.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 039054485d..4b42ad0e13 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2930,9 +2930,17 @@ class Item foreach ($attachments['visual'] as $attachment) { if (!empty($attachment['preview'])) { - $body = str_replace($attachment['preview'], Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_LARGE), $body); + $proxy = Post\Media::getPreviewUrlForId($attachment['id'], Proxy::SIZE_LARGE); + $search = ['[img=' . $attachment['preview'] . ']', ']' . $attachment['preview'] . '[/img]']; + $replace = ['[img=' . $proxy . ']', ']' . $proxy . '[/img]']; + + $body = str_replace($search, $replace, $body); } elseif ($attachment['filetype'] == 'image') { - $body = str_replace($attachment['url'], Post\Media::getUrlForId($attachment['id']), $body); + $proxy = Post\Media::getUrlForId($attachment['id']); + $search = ['[img=' . $attachment['url'] . ']', ']' . $attachment['url'] . '[/img]']; + $replace = ['[img=' . $proxy . ']', ']' . $proxy . '[/img]']; + + $body = str_replace($search, $replace, $body); } } DI::profiler()->stopRecording(); -- 2.39.5