将此代码添加到主题functions.php
文件上载图像时,WordPress会调整图像大小。插件,如Regenerate Thumbnails 可用于确保在首次上载后更改图像大小时正确生成源图像。
// Sets the parameters for the post-thumbnail image size
// https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
add_action( \'after_setup_theme\', \'wpse239844_image_sizes\' );
function wpse239844_image_sizes() {
set_post_thumbnail_size( 470, 370, true ); // $width, $height, $crop
}