Last update at :2024-07-12,Edit by888u
WordPress will automatically generate multiple size versions of images uploaded to the media library. However, many times we adjust the image to the appropriate size before uploading. It is useless to have so many sizes, and it also seriously takes up server hard disk space. , below this site will share the method of prohibiting uploading images to generate multiple size versions in WordPress.
First log in to wordpress and change all the width and height values of the three specifications to zero in the settings - media of the management background.
Then copy and paste the following code into the very end of your theme’s functions.php file and save the file.
//Disable automatically generated image sizes function shapeSpace_disable_image_sizes($sizes) { unset($sizes['thumbnail']); // disable thumbnail size unset($sizes['medium']); // disable medium size unset($sizes['large']); // disable large size unset($sizes['medium_large']); // disable medium-large size unset($sizes['1536x1536']); // disable 2x medium-large size unset($sizes['2048x2048']); // disable 2x large size return $sizes; } add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes'); //Disable scaling add_filter('big_image_size_threshold', '__return_false'); // Disable other image sizes function shapeSpace_disable_other_image_sizes() { remove_image_size('post-thumbnail'); // disable images added via set_post_thumbnail_size() remove_image_size('another-size'); // disable any other added image sizes } add_action('init', 'shapeSpace_disable_other_image_sizes');
Upload the image again and you will find that there is only the original image and no other versions will be generated.
Recommended site searches: Zhenjiang high-defense server, Japanese server free, overseas virtual host, Hong Kong server, permanent free Linux server, virtual host space, registered domain name query, foreign virtual host, dual-line space, mainland China proxy server IP ,
发表评论