【发布时间】:2019-06-15 16:32:18
【问题描述】:
我在functions.php中做过这个:
function wpse_setup_theme() {
add_theme_support( 'post-thumbnails' );
add_image_size( 'small-thumb', 800, 600, true );
}
add_action( 'after_setup_theme', 'wpse_setup_theme' );
如果我这样做:
<? the_post_thumbnail( 'small-thumb' ); ?>
它可以正常工作(拍摄“裁剪”的图像)。但如果我这样做:
<? echo get_the_post_thumbnail_url(get_the_ID(), 'small-thumb') ?>
它总是选择“默认”(完整)图像。与以下相同:
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'small-thumb' );
echo $image[0];
我哪里错了?
【问题讨论】:
-
添加此代码后,您是否重新生成了缩略图?由于添加代码不会重新生成缩略图。
标签: php wordpress thumbnails