在功能中。php您可以定义默认缩略图大小:
// Set featured image sizes
add_theme_support( \'post-thumbnails\');
set_post_thumbnail_size( 320, 320);
然后,您甚至可以定义不同的格式,以便在自定义主题中使用
add_image_size( \'sidebar\', 75, 75, true);
add_image_size( \'gallery\', 159, 159, true);
function custom_gallery(){
global $post;
$args = array(
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'numberposts\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'post_parent\' => $post->ID,
\'exclude\' => get_post_thumbnail_id()
);
$images = get_posts($args);
foreach($images as $image){
if($images){
// use gallery size thumbnails
$thumbnail_array = image_downsize( $image->ID, \'gallery\' );
$thumbnail_url = $thumbnail_array[0];
}
}
}