0

I need to delete the original image file after it has been used as source for generating the defined image styles. I'm fine with the generated images and want to delete the original because of space issues.

I could imagine a drush or cron job which periodically deletes the originals, but I think that would have some negative implications.

Any cleaner solution?

  • 1
    If you delete the original, I think the derivatives will be wiped out (I’m assuming) when cron runs, cache clears or something along those lines. – Kevin May 29 '18 at 20:29
  • Yeah, what @Kevin said, you're not going to want to remove the originals. You can resize images on upload by setting max image resolution on your image field. This can help drastically. You can also adjust the image quality at /admin/config/media/image-toolkit. – sonfd May 29 '18 at 21:08
  • Thing also is: What will happen when you somewhen add new image styles and there is no original image anymore? – leymannx May 29 '18 at 21:35
  • 1
    yeah, this makes no sense whatsoever. you can upload image, generate "image-styled" images out of it, keep those as normal files without additional derivatives and delete the uploaded image. if space is an issue, you got other issues mate :D – user21641 May 29 '18 at 21:45
  • Ok, I see that's a really bad idea to delete the original image. Actually the default Drupal behavior is doing exactly what I need, to forget about the original image if the max. resolution is defined. Sorry for my ignorance, misunderstood the max. resolution configuration at image fields. – geraldo May 29 '18 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.