Home › Forums › General Issues › Limit image sizes created for ACF image field
For the majority of my site I want to have access to the 4 different image sizes created upon upload. However for images uploaded in an ACF Repeater field with Images I only want those to be uploaded at full size, no other sizes created, because these are only going to be used in a slideshow and only one size is needed…the full size.
If I can find a way to not create the other 3 system sizes I will save A LOT of unnecessarily wasted drive space.
300 slideshows with 6 images on average = 1800 images. If I let WP operate normally that is 5400 images on the server that will never be used.
Any thoughts on how to get WP to not create the other 3 sizes for certain things like one ACF Repeater with Images field but let the rest of the normal post & page uploads create those other sizes?
Thanks in advance for any ideas on this.
If you were talking about not creating image sizes for custom images sizes added with add_image_size(), https://developer.wordpress.org/reference/functions/add_image_size/ then I think it would be possible using acf/upload_prefilter https://www.advancedcustomfields.com/resources/acfupload_prefilter/.
I don’t know that it is possible but in this filter you might be able to call remove_image_size() on the custom sized you do not want to create.
But, if you read the documentation for remove_image_size() https://codex.wordpress.org/Function_Reference/remove_image_size it says
Note: Cannot be used on reserved image size names
There isn’t anything in WP that will let you stop WP from creating the 3 images sizes that are built in.
John,
That would at least let me clean up any custom image sizes I had going on.
Based on that…in theory…a possible but complex solution would be to:
– Turn off all the normal “reserved sizes” in the WP Media section under Settings.
– Recreate them all as Custom Sizes in functions.php.
– Setup the remove_image_size for the unnecessary ones when uploaded based on the ACF field.
– And then I would have only the necessary images for the slideshows.
Thanks for your idea!
I didn’t know that you can “Turn of” the normal image sizes. But know, you can’t add a custom size with the same name as a built in size any more than you can remove it.
And to be honest, I’m not 100% sure that the custom image sizes can be removed in the filter I mentioned above, because I’ve never tried it, but I don’t see why you can’t remove them. Even if you do I think you’re going to need to have those standard sizes.
I came across this when doing a search today, I’m sure I’ve seen it before and just forgot. You can probably add a filter using this hook in the acf/upload_prefilter https://developer.wordpress.org/reference/hooks/intermediate_image_sizes_advanced/. It appears that this will let you tell WP exactly what image sizes to generate.
The topic ‘Limit image sizes created for ACF image field’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.