I’m using a lot of thumbnails but never the original file. To save space, I’d like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?
Thanks,
Dennis
I’m using a lot of thumbnails but never the original file. To save space, I’d like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?
Thanks,
Dennis
You must be logged in to post a comment.
I foud another solution in the web. It’s based on the one accepted here, but it takes it even further.
The one, accepted here, removes the main-image and goes on. The solution I found replaces the original image by the image generated for “large”. It just goes on without replacing if this image-resolution is not defined.
This way it is ensured that every script, relying on the original image, will still work as before – for example the thumnail regeneration.
http://www.wprecipes.com/how-to-automatically-use-resized-image-instead-of-originals
EDIT:
@dalbaeb pointed me to an issue written in the comments on the blog-post. I rewrote the code based on the API instead of the solution provided there. It’s not that much of a difference, but just to use the same function calls as in the API 😉
EDIT2:
I had a problem with the code on one client where another size-configuration linked to the large-file. I updated the code accordingly. If you have any kind of problems with it, drop me a mail.
I just created a plugin because I had the same problem. You can download it from here
I know this is very old but I still needed to solve this issue, this may have worked for new images when I used it in functions.php but I did have some issues and images becoming unusable and I also couldn’t harness this to update existing images. I had about 2000 existing images I needed to go through them all and make all ofthe old big images smaller. I created a page on the front end that only an admin can access and used this code.
The big difference here is that instead of deleting the OG image and renaming the ‘large’ image to the OG name. (This did not work for me, I lost quite a few images trying this method) So instead I copied the large image and named the copy the same as the OG image. Hence the big image gets overwritten by the smaller ‘large’ image. Also on the front end, I had to change how the metadata gets updated.
Test this on individual posts first, be sure this works for you before changing numposts to -1. I stupidly lost about 100 images trying to run the original code without carefully checking the results first.
FRONT END CODE TO UPDATE EXISTING IMAGES:
This of course ran into errors several times, I imagine due to some corrupt images. So after trying to go through them all at once and getting errors, I then had to spend some time going through date ranges to be sure I got all of them updated.
CODE FOR NEW IMAGES, In functions.php
The answers above don’t seem to work anymore. I slightly modified the code and the example below works for WordPress 5.5
WordPress disable upload image original
Tested wordpress 5.6
By https://stackoverflow.com/questions/41626139/wordpress-removing-original-image-after-resize
The problem with the solutions above is that the unlinked image is the scaled image from the ‘big_image_size_threshold’. (since WP 5.3)
If you add:
to your functions.php, the solution works!
Found a plugin that do the job very easily Imsanity. Also can resize the original image to prefered size too.