最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Disable globally "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" with Mu

programmeradmin2浏览0评论

I would like to disable the "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" function for all blogs in my WordPress Multisite setup.

This function is available in Dashboard, Settings/Media.

The best solution would be PHP code in wp-config.php or simple plugin.

I would like to disable the "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" function for all blogs in my WordPress Multisite setup.

This function is available in Dashboard, Settings/Media.

The best solution would be PHP code in wp-config.php or simple plugin.

Share Improve this question asked Nov 4, 2019 at 11:51 FerimanFeriman 2892 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

To disable cropping, insert this below code in disable-automatic-image-crop.php file in your mu-plugins folder:

<?php
/*
Plugin Name: Disable Automatic Image Crop
Author: Wordpress Community
Description: https://gist.github/czenzel/0f5888cbbfa4a857e56361dd3bc19b39
*/
add_action( 'init', 'czc_disable_extra_image_sizes' );
add_filter( 'image_resize_dimensions', 'czc_disable_crop', 10, 6 );
function czc_disable_crop( $enable, $orig_w, $orig_h, $dest_w, $dest_h, $crop )
{
    // Instantly disable this filter after the first run
    // remove_filter( current_filter(), __FUNCTION__ );
    // return image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, false );
    return false;
}
function czc_disable_extra_image_sizes() {
    foreach ( get_intermediate_image_sizes() as $size ) {
        remove_image_size( $size );
    }
}
?>

It's completely disabled automatic image cropping for all sizes.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论