Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Kays on June 06, 2013, 01:51:18 PM

Title: Thumbnails not updating if new size is larger than the image
Post by: Kays on June 06, 2013, 01:51:18 PM
Posting this for reference. My repo is way out date else I'd do a commit also.

If the thumbnail size is changed and it is now larger that the existing image. If a thumbnail exists, it does not get resized and is still displayed at the old size.

http://www.simplemachines.org/community/index.php?topic=505297.msg3556832#msg3556832

Here is a fix for that. This will delete the thumbnail and update the database.

In Display.php look for:


if (!empty($attachment['id_thumb']))
$attachmentData[$i]['thumbnail'] = array(


And add before that:


// If the thumbnail size is increased and the image size is now smaller than that. Remove the old thumbnail so it don't show.
if (!empty($attachment['id_thumb']) && $attachment['width'] <= $modSettings['attachmentThumbWidth'] && $attachment['height'] <= $modSettings['attachmentThumbHeight'])
{
require_once($sourcedir . '/ManageAttachments.php');
removeAttachments(array('id_attach' => $attachment['id_thumb']), '', false, false);

$smcFunc['db_query']('', '
UPDATE {db_prefix}attachments
SET id_thumb = {int:id_thumb}
WHERE id_attach = {int:id_attach}',
array(
'id_thumb' => 0,
'id_attach' => $attachment['id_attach'],
)
);

$attachment['id_thumb'] = 0;
}

Title: Re: Thumbnails not updating if new size is larger than the image
Post by: feline on June 06, 2013, 04:11:32 PM
Better way .. create new thumbnails in the admin part, if the size changed. that will work for up- and downsize  ;D
Title: Re: Thumbnails not updating if new size is larger than the image
Post by: shawnb61 on November 25, 2022, 05:34:39 PM
Closing old 2.0 bugs - 2.0 is in security fixes-only at this point.