• Welcome to Simple Machines Community Forum. Please login or sign up.
November 28, 2021, 10:05:28 PM


Want to get involved in developing SMF, then why not lend a hand on our github!

Thumbnails not updating if new size is larger than the image

Started by Kays, June 06, 2013, 01:51:18 PM

Previous topic - Next topic


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.


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}',
'id_thumb' => 0,
'id_attach' => $attachment['id_attach'],

$attachment['id_thumb'] = 0;

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods


Better way .. create new thumbnails in the admin part, if the size changed. that will work for up- and downsize  ;D