Hi, just found this script and I'm finding it useful for my site, but I have noticed the script is reporting some of my extra images (the ones named xx_01.jpg, xx_02.jpg) as being orphaned even if the main image and product is still used.
So I've made a tweak to the code (see below) hope someone finds it useful!
Please note, I've tested it on my site and it works but I've only one site to test on!
It searches for underscore then 2 digits, so shouldn't affect image names containing underscores.
Between line 109 and 110, add the preg_replace, this strips the numbers after the _ in the extra image names.
PHP Code:
// strip zen extra file upload underscaore and number
if (preg_replace('/_[0-9]{2}/', '', $subject)) {
$subjectNew = preg_replace('/_[0-9]{2}/', '', $subject);
} else {
$subjectNew = $subject;
}
Then replace line 114 (change $subject to $subjectNew) so the query searches for the filename without the _ suffix and retains the $subject var for use further on in script.
PHP Code:
$result = $db->Execute( "SELECT products_id, products_status, products_image FROM " . TABLE_PRODUCTS . " WHERE products_image = '" . zen_db_input($subjectNew ) ."'" );
Bookmarks