我厌倦了用bootstrap使WordPress功能的图像响应。使用引导程序使图像响应的方法是
<img src="..." class="img-responsive" alt="Responsive image">
当动态显示特色图像时,我厌倦了在wordpress中使用这种方法。
<img src="<?php the_post_thumbnail( 'jumbo_thumbnail'); ?>" class="img-responsive" alt="Responsive image">
但它不起作用。我知道如果我在那里放一个链接而不是<?php the_post_thumbnail( 'jumbo_thumbnail'); ?>
,它就会起作用。但我正在动态地获取特征图像,这种方法不起作用。
你很接近。完全去掉你的img
标签,使用这个:
<?php
the_post_thumbnail( 'jumbo_thumbnail', array(
'alt' => 'Responsive image',
'class' => 'img-responsive'
) );
?>
the_post_thumbnail
函数将为您输出img
标签。