Archived topic
Hello how to remove adative image auto add of GeneratePress
8 replies · Started by Mr Calvert on January 16, 2021
I want to used adaptive image of Wordpress. So I was go to Setting > Media and setup with size max of image will auto generate with width: 300, 380 and 850 pixel. But when I view source I see it auto have generate different image size is: 768w and 1351w. How to remove auto generate image of Generatepress?
Hi there,
Are you referring to static images added within content here?
I referring adaptive image sir! I was go to setting > media and set thumbnail is 300x, medium is 380x, and large is 850x. I think when I upload one image it only auto crop to 4 image with raw, 300x, 380x, and 850x! But why GeneratePress theme was auto crop and generate more I see have 768pixel image and 1351 pixel (equal with width of raw image), so how to remove that? 768x and 1351 is not neccesary.
Hi there,
GP doesn't generate those additional image sizes, that is a core WP function, it always keeps your Full Image, and creates a medium-large image of 768px.
You can filter the intermediate image sizes using:
https://developer.wordpress.org/reference/hooks/intermediate_image_sizes/
Heres an example of that when removing the medium-large:
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']);
});
For the Full size, you simply need to upload a smaller image size, as theres no simple way to remove the original image that you uploaded.
I was try add. But it not remove. Can you check for me that? my website URL was attach.
Size 768px still available when I add your code:
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']);
});
Hello your code effect. But it need upload new image to effect! how to fix that problem have any way to not upload new image for take effect?
And can you give me code extra to remove both 3 size this?:
2x Medium Large 1536px
2x Large 2048px
Scaled 2560px
You will need to install and run the Regenerate Thumbnails plugins to update existing images.
Those images look like Retina size images, that is not a core function of WP - so you must have a plugin that is generating them.
Can you give me code to remove more than one size need delete?
I was try something like this but it not useful
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']);
return array_diff($sizes,[‘small’];
});
Hi,
You can try my answer here:
https://generatepress.com/forums/topic/why-wordpress-is-generating-additional-image-copies/#post-1453270
Also, pay attention to the syntax of your codes. ‘ and ’ will cause issues. Make sure you use " or '.