OK so I found where it should go, but this code is a bit dangerous as-is. It looks like there’s an SQL call that belongs in Bruno’s previous post so all the images in the gallery get deleted.
Here’s the version that works (in r166):
//add by Bruno
if (isset ($filesExist[$name])) {
//recreate thumb if deleted
if (!isset ($filesExist['tn_' . $name])) {
if (substr(strtolower($name), -4) == ".jpg" || substr(strtolower($name), -5) == ".jpeg") {
$retStr = $mg->createthumb($name, "jpeg", $mg->path_to_gal, "tn_");
if ($retStr != "") {
$handleMessage = $retStr;
}
} else
if (substr(strtolower($name), -4) == ".png") {
$retStr = $mg->createthumb($name, "png", $mg->path_to_gal, "tn_");
if ($retStr != "") {
$handleMessage = $retStr;
}
} else
if (substr(strtolower($name), -4) == ".gif") {
$retStr = $mg->createthumb($name, "gif", $mg->path_to_gal, "tn_");
if ($retStr != "") {
$handleMessage = $retStr;
}
}
}
}
//end add by Bruno
if (substr(strtolower($name),-5) != ".html" && $name != '..' && $name != '.' && strpos($name, 'tn_') !== 0 && strpos($name, 'big_') !== 0 && !array_key_exists($name, $filesExist)) {
EDIT: and actually this seems a bit neater:
//recreate thumb if deleted
if (
isset ($filesExist[$name]) &&
!isset ($filesExist['tn_' . $name]) && (
in_array(
$fileExt=substr(strtolower($name), -4),
array('.jpg','.png','.gif')
) ||
$fileExt=substr(strtolower($name),-5) == '.jpeg'
) &&
$retStr = $mg->createthumb($name, $fileExt, $mg->path_to_gal, "tn_") != ""
) { $handleMessage = $retStr; }
BTW I’m finding this a really handy feature. As well as resizing, you can also use it to tweak your compression settings. Thanks Bruno!