<?php
// First, enable thumbnails if they are not enabled yet
add_theme_support( \'post-thumbnails\' );
/*
* Add image dimensions
*
* name
* width
* height
* crop or resize (true or false)
*
* 99999 means very big number
*/
add_image_size( \'featured-portrait\' , 200 , 99999, false );
add_image_size( \'featured-landscape\' , 99999, 200 , false );
// Next, choose names for these dimension sets
add_filter( \'image_size_names_choose\', \'my_custom_sizes\' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
\'featured-portrait\' => __(\'Portrait, 200px wide\'),
\'featured-landscape\' => __(\'Landscape, 200px high\'),
) );
}
您可以根据需要改变宽度、高度和裁剪。
See add_image_size() for more.