- This topic has 8 replies, 4 voices, and was last updated 3 years, 3 months ago by Elvin.
-
AuthorPosts
-
January 16, 2021 at 10:47 am #1621579Mr Calvert
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?
January 16, 2021 at 4:17 pm #1621819LeoStaffCustomer SupportHi there,
Are you referring to static images added within content here?
January 17, 2021 at 5:09 am #1622176Mr CalvertI 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.
January 17, 2021 at 7:12 am #1622439DavidStaffCustomer SupportHi 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.
January 18, 2021 at 1:10 am #1623127Mr CalvertI 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']); });
January 18, 2021 at 1:45 am #1623150Mr CalvertHello 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 2560pxJanuary 18, 2021 at 6:58 am #1623650DavidStaffCustomer SupportYou 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.
January 18, 2021 at 9:46 am #1623927Mr CalvertCan you give me code to remove more than one size need delete?
I was try something like this but it not usefuladd_filter('intermediate_image_sizes', function($sizes) { return array_diff($sizes, ['medium_large']); return array_diff($sizes,[‘small’]; });
January 18, 2021 at 4:46 pm #1624303ElvinStaffCustomer SupportHi,
You can try my answer here:
https://generatepress.com/forums/topic/why-wordpress-is-generating-additional-image-copies/#post-1453270Also, pay attention to the syntax of your codes.
‘
and’
will cause issues. Make sure you use"
or'
. -
AuthorPosts
- You must be logged in to reply to this topic.