Skip to content

Commit

Permalink
Shows full size images, not thumbnails, for attachments in editor
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Mar 26, 2023
1 parent ebf92ca commit fa0b7a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/ShowAttachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<img src="' . $currentAttachment['href'] . '"' . $alt . $title . ' class="bbc_img">';
else
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/scripts/jquery.sceditor.smf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<a href="' + smf_scripturl + '?action=dlattach;attach=' + id + ';type=preview;file"' + attribs + '>' + content + '</a>';
return '<a href="' + smf_scripturl + '?action=dlattach;attach=' + id + ';preview;file"' + attribs + '>' + content + '</a>';
// Show our purdy li'l picture
else
return '<img' + attribs + ' src="' + contentUrl + '">';
Expand Down

0 comments on commit fa0b7a2

Please sign in to comment.