Image Cleaner

wrong path in local installation - Image Cleaner

wrong path in local installation

by raiwa » Sun Feb 23, 2025 10:06 am

When trying to move images I get this error:
The file C:\laragon\www\xxxxxxxx\images\009-23655-25-850-270-5-Thumbnail.png could not be moved to unused/C:\laragon\www\xxxxxxxxx\images\009-23655-25-850-270-5-Thumbnail.png

It would be also nice to have it looking in the pages_description table -> pages_text, advert images, manufacturer description and importers description.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: wrong path in local installation

by raiwa » Sun Feb 23, 2025 5:07 pm

O.K. I got it to work under windows adding a check for path separator:
In: includes\apps\imageCleaner\imageCleaner.php line 45 forward changed to:

Code: Select all

                if ($add == 0) {
                  if (DIRECTORY_SEPARATOR === '\\') {
                    $image_path = str_replace('/', '\\', DIR_FS_CATALOG . 'images/');
                  } else {
                    $image_path = DIR_FS_CATALOG . 'images/';
                  }
                  $details[] = str_replace($image_path, '', $fileinfo->getRealPath());
                }
and replacing backslash path separator:
In: admin\includes\actions\image_cleaner\move_files.php line 27 added:

Code: Select all

            if (DIRECTORY_SEPARATOR === '\\') {
              $unused_image = str_replace('\\', '/', $unused_image);
            }
Still missing to iterate through the directories if the image is in a deeper level than one subdirectory in images/
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: wrong path in local installation

by frankl » Mon Mar 03, 2025 7:20 am

Thank you.

Addon updated with changes.

Will add other searches in next iteration.
frankl
Builder
Posts: 159
Joined: Tue Feb 23, 2021 8:39 pm
Phoenix Version: v1.1.0.4
Contact:

Re: wrong path in local installation

by raiwa » Mon Mar 03, 2025 10:11 am

The update to:

Code: Select all

DIR_FS_CATALOG . DIR_WS_CATALOG . 'images/'
is wrong. DIR_FS_CATALOG includes already the DIR_WS_CATALOG directory.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: wrong path in local installation

by raiwa » Mon Mar 03, 2025 2:24 pm

To avoid duplicated work, I post my modified version:
- checks for categories, importers and adverts images and in pages, manufacturers and importers description.
- added functionality to save the exception list in a hidden configuration entry and modified the labels according to my changes.
- fixed wrong paths and tested under local windows and public server installation.
raiwa_version_1.2.zip
(17.87 KiB) Downloaded 51 times
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: wrong path in local installation

by frankl » Tue Mar 11, 2025 3:26 am

Awesome, thank you so much Rainer!
frankl
Builder
Posts: 159
Joined: Tue Feb 23, 2021 8:39 pm
Phoenix Version: v1.1.0.4
Contact: