• Hi Julia

    Thanks for this great plugin.

    When I uploaded 6 images for an SKU 1000 to my WooCommerce site, the plugin helped generated about 60 image files which is good. Later, I edited one of the 6 images and re-uploaded all 6 images to the same SKU 1000. Another 60 image files were generated. I re-uploaded the 6 images to the same SKU 1000 for the 3rd time, I now have 180 image files on the server. The first 120 image files would be I called deadweights. I don’t need them anymore. The latest 60 images should be the only image files to stay on the server. See https://pasteboard.co/UsleTxHmvMFH.png

    Can I run some clean up tool to recover the space of the first 120 image files since these 120 images are redundant?

    Is this the correct tool to do run? See https://pasteboard.co/RvWKGqGZdE6O.png

    Thank you very much.

    Best regards

    Mak Koon Hung

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hi,

    Yes, you can use my plugin for such a cleanup. What I advise would be these:

    1. configure the plugin to disable the background generation of the WooCommerce images
    2. setup some rules that for the products and product variations to only generate the actual image sizes you will use (most of the times these are woocommerce_thumbnail, woocommerce_single, woocommerce_gallery_thumbnail, so the rest can be set to ignore)
    3. run a raw cleanup just for the products and product variations images
    4. regenerate only the 3 image sizes for products and product variations

    If you think there is some potential risk with running bulk cleanups, you can always just test with one single image. You can identify one image attached to the product that you want to cleanup (in the info lightbox you can see all the image files generated, or also in the media listing), then click the raw cleanup button, the regenerate only the image sizes you want.

    Let me know how it goes.

    Regards,
    Iulia

    Thread Starter makkh1

    (@makkh1)

    Hi Julia

    Thank you for your prompt reply. Much appreciated.

    Does disabling background generation of WooCommerce images prevent creating “deadweights”, did I get that correct? Because each time I upload a new set of image files for an SKU, the old set of image files are stubbornly still on the server as “deadweights”.

    I have about 20,000 SKUs now and all are simple products. No variations. I am doing some basic calculations: Each SKU has about 10 images. Therefore, I am having about 200,000 image files now. Running the regen tool will produce about 2,000,000 image files altogether.

    On a typical day, about 20 SKUs will have their images edited and re-uploaded. As mentioned earlier, a few hundred redundant “deadweight” files will be generated and these files need to be removed. Do you have a command line tool or command to clean up? The web tool kept crashing after working for a while, that is, it managed to process only a few hundred SKUs. There are several thousand SKUs left unprocessed. I cannot really see the “deadweights” removed. You also mentioned RAW cleanup, is this the correct way to do RAW cleanup? I clicked on just this one button: https://pasteboard.co/RvWKGqGZdE6O.png

    Where did I do wrongly?

    Thank you very much.

    Best regards

    Mak

    Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hi Mak,

    Yes, there has to be a combination of disabling the background generation of images from WooCommerce + your own custom rules for products (you can do that from the plugin “Advanced rules”) + cleanup of already generated images.

    If you click the info icon near the “Keep only the original/full size files” option you will see a WP-CLI command that you can replicate in your terminal (it will prompt for arguments). If I understand what you want to do, the command would be similar to wp sirsc rawcleanup 1 product --v. In any case, typing in your terminal wp sirsc you will get hints about the available commands.

    If you want to remove only one image size for a test, then just run something like wp sirsc cleanup 1 product and you will then be prompted to write the image size you want to remove. Adding –v flag to the command will show you the whole execution.

    Give it a try and let me know how it goes.

    Regards,
    Iulia

    Thread Starter makkh1

    (@makkh1)

    Hi Julia

    Thanks once again.

    I installed WP-CLI on my Windows Server 2012r12 and ran the rawcleanup command for one product SKU as per your instructions:
    wp sirsc rawcleanup 1 product --v
    It seems to be processing all images for all my 20,000+ SKUs although only a few hundred SKUs are having images in them at this time. The command completed successfully without crashing, but ended up cleaning up only a faction of the images (much better than running it on the webbrowser cleaning up nothing).

    What could the reason be for not completely removing all the “deadweights”?

    Please see my attached screenshot.
    https://pasteboard.co/eGWLg5sxkFu5.png
    Take just 1 image file 1-6.jpg for example: a lot of old files are still there, eg. 1-6, 1-6-1, 1-6-2, 1-6-3. I uploaded the same 1-6.jpg 5 times for SKU 1, therefore only the last image file 1-6-4 is valid. All other 1-6-? are to be removed.

    Thank you very much.

    Best regards

    Mak

    Thread Starter makkh1

    (@makkh1)

    Hi Julia

    I disabled WooCommerce background generation, and then uploaded 6 image files for 1 Astex SKU.
    See this pic for the 6 new image files: https://pasteboard.co/vWnMJ2uvlEPm.png

    I re-uploaded the same 6 images to the same 1 Astex SKU.
    See this pic for the 6 new image files + 6 “deadweights” created just now: https://pasteboard.co/MeMDCNRA3Fwm.png

    Then I ran the WP-CLI command:
    wp sirsc rawcleanup 1 product --v

    After 15 minutes, the command ended successfully, I checked the image files for 1 Astex SKU, all 12 files are still there. Is there something I have done wrongly?

    Thank you very much.

    Best regards

    Mak

    Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hi Mak,

    The screenshots are not there anymore (sorry for the late response).
    However, the raw cleanup removes the files associated with image sizes and keeps only the uploaded file.

    This means that if you uploaded the image 1-6.jpg through the native WP functionality, the images would generate a list of files following the logic below (-150x150 is the image size suffix):
    – 1-6-150×150.jpg
    – 1-6-300×400.jpg
    – 1-6-0x800.jpg

    – 1-6.jpg

    In the WordPress images context, 1-6.jpg and 1-6-1.jpg are not related, nor linked as something resembling images sizes.

    In the case of running the raw cleanup, the files that would get removed are 1-6-150x150.jpg, 1-6-300x400.jpg, and 1-6-0x800.jpg, and the rest of the files that are images sizes following the native naming convention.

    I hope this description answers better to your question.

    Have a nice weekend!
    Iulia

    @makkh1 Assuming your 3 uploads have separate entries in the media library, deleting them should get rid of all of their registered thumbnails.

    The IRSC cleanup is good for when you change the image size definitions.

    To update images “in place”, i.e. using the same media attachment record, you can use a plugin that replaces images. In fact, Iulia has written one: https://www.ads-software.com/plugins/easy-replace-image/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Recover space from obsolete image files’ is closed to new replies.