我想在WordPress多站点设置中为所有博客禁用“将缩略图裁剪到精确尺寸(通常缩略图是成比例的)”功能。
此功能可在仪表板、设置/媒体中使用。
最好的解决方案是wp config中的PHP代码。php或简单插件。
我想在WordPress多站点设置中为所有博客禁用“将缩略图裁剪到精确尺寸(通常缩略图是成比例的)”功能。
此功能可在仪表板、设置/媒体中使用。
最好的解决方案是wp config中的PHP代码。php或简单插件。
要禁用裁剪,请在中插入以下代码disable-automatic-image-crop.php
mu插件文件夹中的文件:
<?php
/*
Plugin Name: Disable Automatic Image Crop
Author: Wordpress Community
Description: https://gist.github.com/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 );
}
}
?>
它完全禁用了所有尺寸的自动图像裁剪。自从order allow,deny 在2.4中被弃用,我想在中重写规则。htaccess文件以使用新规则。之前我使用:<files wp-config.php> order allow,deny deny from all </files> 我将其改写为:<FilesMatch \"wp-config.php\"> Require all denied </FilesMatch>&#