How to Automatically Delete Woocommerce Images After Deleting a Product?

Поділитися
Вставка
  • Опубліковано 3 лис 2024

КОМЕНТАРІ • 82

  • @KimMøller-o5p
    @KimMøller-o5p Рік тому

    I rarely comment on youtube. But thank you. I solved my problem that my server was filled with photos. Now i can clean. Have a nice day. And a nice summer. Thank you

  • @luxdevine
    @luxdevine 10 місяців тому

    Thank you, thank you, thank you! You have saved me so much time. It works like a dream! 👏 And you have a new subscriber. All the best!

  • @1mrk2mrk22
    @1mrk2mrk22 2 роки тому

    Thank you very much. This is what we need and is very important. You were wonderful with this important addition that I needed and everyone who had a store needed. Thank you very much

  • @RiccardoTurcato
    @RiccardoTurcato Рік тому

    Very useful but, if some images are used in more than one product (i.e. gallery images) this script delete or bypass?

    • @wpsimplehacks
      @wpsimplehacks  Рік тому

      It’s been a while since I made this video and used this code myself, so I’m not exactly sure. Can you test it and let me know?

  • @milomurphy1108
    @milomurphy1108 2 роки тому

    Thanks for this, it works great!! However I do have one question... Is there a way to include any variable product specific images too in this? It only appears to delete the main image for me and not the additional images we use at the variable level

  • @k3nsh1n07
    @k3nsh1n07 3 роки тому

    Hello, thank you! I have one question, if I already deleted the product, it is possible to delete the images ?

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому +1

      Not with that snippet.

    • @k3nsh1n07
      @k3nsh1n07 3 роки тому

      @@wpsimplehacks Thats what I thought, thank you!!

  • @browsbuyshop230
    @browsbuyshop230 3 роки тому

    please suggest the best and fast theme according to google page speed analytics

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Blocksy and Kadence are currently two of the best WordPress themes. So, if you’re interested, then you can grab:
      🔵 Kadence theme here: wpsimplehacks.com/kadence (SAVE 10% Coupon SIMPLEHACKS)
      🅱️ Blocksy theme wpsimplehacks.com/blocksy (SAVE 10% Coupon WPSH10)

  • @Ekowreelstudios
    @Ekowreelstudios 3 роки тому

    which code did you paste, i am lost cos i didn't find any code.

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      There’s a link In the description of the video.

  • @naluwebdesign
    @naluwebdesign Рік тому

    Is there a way to do this if the product is out of stock? We don't want to delete the product but we want to update the image once the new stock arrives because the product image will vary.

  • @humbertg.9661
    @humbertg.9661 3 роки тому

    Does it work even if I don't want to delete the product but just the images associated to products?

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      It will delete images ONLY if you delete the product. So, if you want to delete only images then use Media library for it.

  • @satendrakumar8272
    @satendrakumar8272 2 роки тому

    Hi I have activated the Code Snippetts plugin but it does not delete the images when I click delete permanately in trash products

    • @wpsimplehacks
      @wpsimplehacks  2 роки тому

      I just re-tested it on my site and everything works as shown in the video.

  • @NOALNOM
    @NOALNOM 2 роки тому

    AMAZING SNIPPET TRICK!!! 👏👏👏

  • @aadilashfaqofficial
    @aadilashfaqofficial 2 роки тому

    very helpful. you made my life easier. Love from Pakistan

  • @ducanhnguyen6197
    @ducanhnguyen6197 3 роки тому

    Can It delete review images on product pages (not just product images? Thanks

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому +1

      Not with that snippet. You have to find another solution, I don’t have any for it so far.

  • @YasienSarlie
    @YasienSarlie 3 роки тому

    Loving your tutorials, thank you. I am looking for a solution, shortcode or similar, I want to display a section of the current products related categories or sub categories products. So if a party theme has 12 products, all those product need to appear on any of its single products page

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому +1

      See whether this plugin helps you out wordpress.org/plugins/custom-related-products-for-woocommerce/

    • @YasienSarlie
      @YasienSarlie 3 роки тому

      @@wpsimplehacks thanks... Recall been enjoying your videos. Makes me realise how little I know. Thank you

  • @satendrakumar8272
    @satendrakumar8272 2 роки тому

    I am adding the Snippett
    "Delete woocommerce product images after product deletion"
    the following error
    The code snippet you are trying to save produced a fatal error on line 1:
    syntax error, unexpected 'woocommerce' (T_STRING)

    • @wpsimplehacks
      @wpsimplehacks  2 роки тому

      I just re-tested it on my site and everything works as shown in the video.

  • @pixelabdigital
    @pixelabdigital 3 роки тому

    Hi!, Thanks for sharing this code , it works great deleting the image in media library but it doesn't delete the server files, they are stilll available on the server but not showing on media library. Can you help with any idea what could be missing?. Thanks

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Hmm... Just tested on two on my sites and it is working well on those. Therefore, I don't know the issue may be.

    • @pixelabdigital
      @pixelabdigital 3 роки тому

      @@wpsimplehacks I just found out that the plugin WPML was letting the image on the server, when the product was deleted, it delete just for 1 language and left the image for other languages, I found a 'When deleting a post, delete translations as well' option and then works great. Thanks your your reply and code!

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Thank you for the follow-up

  • @محمدحمدين-ظ7ذ
    @محمدحمدين-ظ7ذ 3 роки тому

    Best content you provide 💯💯

  • @MariaLeonTri
    @MariaLeonTri 2 роки тому

    Woooooooooooo Thank you!!!!! Love Youuuuuu !👏👏👏

  • @zaeemjaved6850
    @zaeemjaved6850 3 роки тому

    How can i only delete varation images when variation is deleted? Could you please help me a lil here?

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Sorry, I don’t know the answert to that question.

    • @zaeemjaved6850
      @zaeemjaved6850 3 роки тому

      @@wpsimplehacks Oh, well thankyou for a quick reply.

  • @timk643
    @timk643 3 роки тому

    I tried to enter it in the functions php but then I got a critical error on my side. After this I tried to enter it via code snippet plugin but got this message:
    The snippet has been deactivated due to an error on line 4:
    Cannot redeclare function delete_product_images.

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Just re-tested on my other site and works well.
      Did you delete the snippet from the functions.php before adding it to Code snippets? If not then delete it because you can use the function only in one place.

  • @ShanksAutographs
    @ShanksAutographs 3 роки тому

    Hey how do I set the product to automatically delete after I sell the item ?

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Sorry, I don’t have that kind of snippet

  • @comercymarketing6695
    @comercymarketing6695 10 місяців тому

    Thank you very much!!

  • @NOALNOM
    @NOALNOM 2 роки тому

    Thanks for sharing! It would be more awesome if you could share the adaptation of this snippet but for delete images for regular blog posts, as you know each image uploaded from every blog post, WP generate 4 to 8 thumbnails images that are slowly filling the server. Did you know a way to effectively delete all unused images from upload media folder as well erase ID images from database? Great channel CONGRATS! 👏👏👏🥳🥳🥳

  • @VideoChannelCAnet
    @VideoChannelCAnet 2 роки тому

    does anybody know how comes that in my environment images are not deleted from the server? of course the script works very good for media library

  • @badreddine8039
    @badreddine8039 11 місяців тому

    Thank you

  • @AdamSno
    @AdamSno Рік тому

    The snippet has been deactivated due to an error on line 5:
    Cannot redeclare function delete_product_images.

    • @wpsimplehacks
      @wpsimplehacks  Рік тому

      I just tested it on my site and everything works well. See here cln.sh/UvUm0v

  • @heinojuurikas8493
    @heinojuurikas8493 3 роки тому

    Otsisin seda juba ammu. Tänud!

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Vaeh-vaeh, keda siin kanalil näha :) Tore, et aitas

  • @kiran9551
    @kiran9551 3 роки тому

    How to delete only gallery images and exclude featured image?

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Sorry, I don’t have this solution for you.

  • @metsavend112
    @metsavend112 Рік тому

    Kõlad nagu eestlane :D
    AItäh!

    • @wpsimplehacks
      @wpsimplehacks  Рік тому +1

      Sa kõlad ka nagu eestlane :) Võta heaks.

  • @manyanastuff108
    @manyanastuff108 3 роки тому

    I got this on instalation can you advise please
    Don't Panic
    The code snippet you are trying to save produced a fatal error on line 23:
    syntax error, unexpected end of file
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.
    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      This means that you did not copy the whole code. Pay attention that the code ends with three brackets }.
      It seems that you did not copy the third one.

  • @creatnz
    @creatnz Рік тому

    Bro both the codes are different..

    • @wpsimplehacks
      @wpsimplehacks  Рік тому

      What do you mean by that?

    • @creatnz
      @creatnz Рік тому

      Basically what you have shown in the video and what i got in the website both codes are different..and apparently it is not working on site .after deleting the product its still stay there in media library

    • @wpsimplehacks
      @wpsimplehacks  Рік тому

      1) How is this code shown in the video (screenshot cln.sh/7YAZIp) different than the code in my site here wpsimplehacks.com/how-to-automatically-delete-woocommerce-images/
      2) I just tested the code on my site, and it still works well

    • @creatnz
      @creatnz Рік тому

      It is seems working brother .iam so sorry. Thank you ..

  • @NOALNOM
    @NOALNOM 2 роки тому

    HELLO!!!

  • @silentphil77
    @silentphil77 3 роки тому

    code snippet seems to be hidden from mere mortals

    • @wpsimplehacks
      @wpsimplehacks  3 роки тому

      Good call, Phil ;)
      It’s here wpsimplehacks.com/how-to-automatically-delete-woocommerce-images/

    • @silentphil77
      @silentphil77 3 роки тому

      @@wpsimplehacks thanks heaps!.... BTW your content is brilliant mate!

  • @marcoprofwebsitenl6484
    @marcoprofwebsitenl6484 2 роки тому

    Thanks for this video. If you want to delete media directly you should add define('EMPTY_TRASH_DAYS', 0);. And if you only want to delete specific media you should delete them by ID 😉