• Resolved abotimon

    (@abotimon)


    Hello,
    I’m using wordpress 5.2.2 with Woocommerce 3.7.0

    We’re using the standard Woocommerce API to fill up our webshop with products from our ERP software. But we are having some issues with the images.

    When sending products to the shop we upload the images to a folder on the server /public_html/images then the API takes them and put them into /public_html/wp-content/uploads/2019/08

    The image name is the articlenumber, for example we send product ABCD to the webshop. It will be placed in the images folder as ABCD.jpg and then in the wordpress folder where the API will create the necessary formats, so in the wordpress folder we’ll have:

    ABCD.jpg
    ABCD.jpg-100×100.jpg
    ABCD.jpg-150×150.jpg
    ABCD.jpg-300×300.jpg
    ABCD.jpg-214×300.jpg
    ABCD.jpg-450×630.jpg

    The problem is the next time we send that product to the shop (if something was changed with the product) the API will put the images in the wordpress folder again instead of recognizing it’s already there. So it will add:

    ABCD-1.jpg
    ABCD.jpg-1-100×100.jpg
    ABCD.jpg-1-150×150.jpg
    ABCD.jpg-1-300×300.jpg
    ABCD.jpg-1-214×300.jpg
    ABCD.jpg-1-450×630.jpg

    So now for 1 article I already have 14 images. Next time the product get’s exported again it will add it with ABCD-2.jpg etc…

    And before we know it the whole disk is full because of all these images. Is there anyone else with this problem that found a solution?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter abotimon

    (@abotimon)

    Seriously, no one else with this issue? This is a such a big design flaw in Woocommerce and I can’t imagine that I’m the only one that wants a solution for this.

    We have webshops with a couple of 10000 products that now need over 100GB of diskspace on the server because of this problem.

    Hey @abotimon,

    I’d suggest making a bug report about this on GitHub.

    https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=&template=Bug_report.md&title=

    That’s the best spot to report suspected bugs.

    Take care

    Thread Starter abotimon

    (@abotimon)

    Hi,

    Ok I will do that. Thanks for the reply!

    Thread Starter abotimon

    (@abotimon)

    I got an answer back, thought I would share it here:

    You should ommit the image from the second request if nothing has changed. When making a POST request to update a product you should ideally only be posting the data that has changed.
    TBH there is really no way for us to know if an image is identical without doing a lot of expensive comparisons, for example, an image may be cropped and uploaded with the same name, having to read image data and compare it with each request will be very expensive and resource-intensive causing API requests to be slow.
    Closing this as won’t fix for now as there is a workaround by not posting data that has not changed to the API.

    Hey @abotimon,

    Thanks for posting the response here from GitHub. That helps us all learn.

    Cheers

    Thread Starter abotimon

    (@abotimon)

    You’re welcome and thank you for the tip to make a post on their Github!

    I’m not a developer myself but I don’t really see why they think it would be hard to see if it’s the same image. If they would just check if it’s the same size (in bytes) then you would know. But again, not a developer myself so it might sound easy in my head but in practise not so much haha.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Woocommerce API creates duplicate images’ is closed to new replies.