据我所知image_size_names_choose
挂钩(参见https://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose).
示例:
// add your custom size
function my_setup_image_sizes() {
add_image_size( \'wide-image\', 900, 0);
}
add_action( \'after_setup_theme\', \'my_setup_image_sizes\' );
// add custom size to editor image size options
function my_editor_image_sizes( $sizes ) {
$sizes = array_merge( $sizes, array(
\'wide-image\' => __( \'Image 900px wide\' )
));
return $sizes;
}
add_filter( \'image_size_names_choose\', \'my_editor_image_sizes\' );
NOTE 如果要为现有图像定义新的图像大小,则必须重新生成缩略图
NOTE 2 基本图像大小必须大于内部指定的尺寸add_image_size
作用