Support » Plugin: WooCommerce » Question about Media Library

  • Resolved teuptworkshop

    (@teuptworkshop)


    I have a simple question about the media library, but as it is important for me and tricky to test it properly (I have so many products) I prefer to just ask it here to be 100% sure.

    I have a store with many thousands of products, that I import from elsewhere. Most of the time when I sync, it’s just a minor update of the product data, but once in a while I will want to delete the entire product collection and reupload it fresh.

    I’ve noticed that the product images are transferred from their original URL into the Media Library and the products source them from there.

    Here’s my question: If I delete and reupload all of my products, is it important that I wipe the whole Media Library? Does WooCommerce recognise images that are already in it, or would it recopy them into the media library and leave me with thousands of duplicate images?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi there,

    If I delete and reupload all of my products, is it important that I wipe the whole Media Library? Does WooCommerce recognise images that are already in it, or would it recopy them into the media library and leave me with thousands of duplicate images?

    That depends on how you reupload the products. Do you do it manually or do you use an importer. If it is an importer, which one exactly do you use?

    Kind regards,

    Thanks for your reply. I use the standard CSV import.

    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi again,

    I did a quick search.

    Core CSV importer:
    https://docs.woocommerce.com/document/product-csv-importer-exporter/#images

    Does WooCommerce recognise images that are already in it, or would it recopy them into the media library and leave me with thousands of duplicate images?

    Defining the image name only my-image.png should have the importer look for the image and match your product to it. https://d.pr/i/UgfPxN
    I would try this out with a handful of test imports, but I think that will save you the trouble of deleting the entire media library.

    Kind regards,

    Thanks. OK, I have around 20000 images and many have the same name (they’re structured in folders). And I do not keep track of what is and what is not in my library, so I cannot check whether I can specify the name only or whether I should provide the full URL – so this is not an option.

    I guess that means that I will end up with duplicates, so I will need to erase all of my product images first.

    What is the best way to do this? Preferrably without deleting the static images of my store such as logos and such.

    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi again,

    What is the best way to do this? Preferrably without deleting the static images of my store such as logos and such.

    I like using: https://wordpress.org/plugins/media-cleaner/ to automatically delete unused images.

    Kind regards,

    Will try that, thanks!

    I just ran a small test with a single product – I deleted it without deleting the image. Then I did a CSV update which added that product. It seems that NO new image was created, it still uses the image with the “arbitrary” name that WordPress had generated for it.

    I looked at the image properties in the Media Library and noticed that it has a field called “_wc_attachment_source” and it contains the original URL of the image at the time it was added to the Media Library. Probably, before adding new images in the library, the import first scans through the library to check if there are any media that have a “_wc_attachment_source” field that matches the URL in the CSV, and skips those. That’s pretty cool! (Though I am not sure what happens in case the image has changed)

    So I think this all works pretty well, but if anyone sees something I overlooked I’d appreciate to hear about it ๐Ÿ™‚

    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Hi again,

    Probably, before adding new images in the library, the import first scans through the library to check if there are any media that have a โ€œ_wc_attachment_sourceโ€ field that matches the URL in the CSV, and skips those. Thatโ€™s pretty cool

    That is exactly what it does, yes.

    (Though I am not sure what happens in case the image has changed)

    I think the URL is the only parameters. Any change detection would need a size or date parameter additionally, but I think that is not available.

    So I think this all works pretty well, but if anyone sees something I overlooked Iโ€™d appreciate to hear about it ๐Ÿ™‚

    ๐Ÿ‘
    Thanks for sharing your insights here!

    Kind regards,

    Great, yeah that makes sense. Thanks for confirming!

    Plugin Support Con Schneider

    (@conschneider)

    Automattic Happiness Engineer

    Great, yeah that makes sense. Thanks for confirming!

    You are welcome!
    ๐Ÿ‘‹.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.