当 wordpress 中的图像标签中有 class 时,如何使图像动态化?

How to make image dynamic when there is class in image tag in wordpress?

很棒的社区! 如何在图像标记中有内联 css class 的情况下使图像动态化。如果我用 post_thumbnail 函数删除所有图像标签,样式就会丢失。我尝试使用以下代码,但它显示在下面的图像中 ( " /> )。single image 你能告诉我如何解决这个问题吗?非常感谢

<a href="<?php the_permalink(); ?>"><img class="img-responsive img-blog" src="<?php the_post_thumbnail(); ?>" /></a>

函数the_post_thumbnail已经输出了一个img标签。所以您的代码必须如下所示:

<a href="<?php the_permalink(); ?>">
  <?php 
     the_post_thumbnail('large', array( 'class' => 'img-responsive', 'img-blog' ));
  ?>
</a>