From fa0b7a2bf2a093030f59700efd2c1065112df285 Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Sat, 25 Mar 2023 15:14:09 -0600 Subject: [PATCH] Shows full size images, not thumbnails, for attachments in editor Signed-off-by: Jon Stovell --- Sources/ShowAttachments.php | 2 +- Sources/Subs.php | 3 +++ Themes/default/scripts/jquery.sceditor.smf.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/ShowAttachments.php b/Sources/ShowAttachments.php index 1db74123d60..9644f22ba5c 100644 --- a/Sources/ShowAttachments.php +++ b/Sources/ShowAttachments.php @@ -289,7 +289,7 @@ function showAttachment() } // Update the download counter (unless it's a thumbnail or resuming an incomplete download). - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0 && empty($context['skip_downloads_increment'])) + if ($file['attachment_type'] != 3 && empty($showThumb) && empty($_REQUEST['preview']) && $range === 0 && empty($context['skip_downloads_increment'])) $smcFunc['db_query']('', ' UPDATE {db_prefix}attachments SET downloads = downloads + 1 diff --git a/Sources/Subs.php b/Sources/Subs.php index 6d794d2e989..0cd1696bcad 100644 --- a/Sources/Subs.php +++ b/Sources/Subs.php @@ -1769,6 +1769,9 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra // Image. if (!empty($currentAttachment['is_image'])) { + // Just viewing the page shouldn't increase the download count for embedded images. + $currentAttachment['href'] .= ';preview'; + if (empty($params['{width}']) && empty($params['{height}'])) $returnContext .= ''; else diff --git a/Themes/default/scripts/jquery.sceditor.smf.js b/Themes/default/scripts/jquery.sceditor.smf.js index 6eec73779bd..dde8956b7a1 100644 --- a/Themes/default/scripts/jquery.sceditor.smf.js +++ b/Themes/default/scripts/jquery.sceditor.smf.js @@ -728,14 +728,14 @@ sceditor.formats.bbcode.set( if (typeof attrs.height !== "undefined") attribs += ' height="' + attrs.height + '"'; - var contentUrl = smf_scripturl +'?action=dlattach;attach='+ id + ';type=preview;thumb'; + var contentUrl = smf_scripturl +'?action=dlattach;attach='+ id + ';preview;image'; contentIMG = new Image(); contentIMG.src = contentUrl; } // If not an image, show a boring ol' link if (typeof contentUrl === "undefined" || contentIMG.getAttribute('width') == 0) - return '' + content + ''; + return '' + content + ''; // Show our purdy li'l picture else return '';