Archived topic
multiple images
3 replies · Started by Charles on January 25, 2022
Hello,
So I've noticed that over the past months WP has started to add a bunch of new responsive images to my media library. That's creating a storage problem for me
I saw this article: https://perishablepress.com/disable-wordpress-responsive-images/
It said the first thing to do is to get a list of my registered image sizes.
And then I read this article
https://wp-mix.com/wordpress-display-all-registered-image-sizes/
Which suggested putting this code into my theme template
global $_wp_additional_image_sizes;
print '<pre>';
print_r($_wp_additional_image_sizes);
print '</pre>'
I was a bit unsure -- do I put this in functions.php?
Thank you
Hi Charles,
The theme's functions.php is not supposed to be modified.
You can use one of the method introduced in the below article to add PHP code:
Adding PHP: https://docs.generatepress.com/article/adding-php/
I might want to get rid of all of the WP-generated responsive images and just keep the original in the media library. Is there code that would do that?
Give this a try:
function remove_max_srcset_image_width( $max_width ) {
return false;
}
add_filter( 'max_srcset_image_width', 'remove_max_srcset_image_width' );
function yh_disable_srcset( $sources ) {
return false;
}
add_filter( 'wp_calculate_image_srcset', 'yh_disable_srcset' );