Current location:
Home > 未分类 > 禁用WordPress自动生成不同尺寸的图片

禁用WordPress自动生成不同尺寸的图片

在主题functions.php文件中添加以下代码段:

// 禁用自动生成的图片尺寸开始
function shapespace_disable_image_sizes($sizes) {
unset($sizes['thumbnail']); // 禁用缩略图尺寸
unset($sizes['medium']); // 禁用中等尺寸
unset($sizes['large']); // 禁用大尺寸
unset($sizes['medium_large']); // 禁用中大型尺寸
unset($sizes['1536x1536']); // 禁用2x中大型尺寸
unset($sizes['2048x2048']); // 禁用2x大尺寸
return $sizes;
}
add_action('intermediate_image_sizes_advanced', 'shapespace_disable_image_sizes');

// 禁用缩放尺寸
add_filter('big_image_size_threshold', '__return_false');

// 禁用其他图片尺寸
function shapespace_disable_other_image_sizes() {
remove_image_size('post-thumbnail'); // 禁用通过set_post_thumbnail_size()添加的图片
remove_image_size('another-size'); // 禁用任何其他添加的图片尺寸
}
add_action('init', 'shapespace_disable_other_image_sizes');
// 禁用自动生成的图片尺寸结束

Fonts downloaded from the "Free Fonts" column can be used commercially without purchasing copyrights. They are carefully verified by multiple parties before being released. However, it cannot be ruled out that the copyright holder or font author modifies the license one day, or that there are inadvertent omissions in the verification process. Therefore, in actual commercial use, it is recommended to contact the copyright holder or font author for further verification.

The fonts are from the Internet or personal contributions. They are only for personal non-commercial download. Please do not use them for commercial purposes. If you use them for commercial purposes, please contact the font author or the font copyright owner. If there is any infringement, please contact us to disconnect the link.Email:fontsvip@gmail.com

Although we have indicated the license type, please make sure to double check it by reading the information shown in the details area of each font to avoid any confusion. If you are not sure, do not hesitate to contact the font author.