duandun2218 2014-10-09 20:39
浏览 54
已采纳

如何使用Bootstrap响应图像并在wordpress上使用它?

I tired to make WordPress featured image responsive with bootstrap. The way to make the image responsive with bootstrap is

<img src="..." class="img-responsive" alt="Responsive image">

I tired to use this method in wordpress when showing the featured image dynamically.

<img src="<?php the_post_thumbnail( 'jumbo_thumbnail'); ?>" class="img-responsive" alt="Responsive image">

But it doesnot work. I know if I put a link there instead of <?php the_post_thumbnail( 'jumbo_thumbnail'); ?> it will work. But I am dynamically getting the featured image, and this method doesnot work.

  • 写回答

1条回答 默认 最新

  • dqfxao2898 2014-10-09 20:56
    关注

    You're close. Get rid of your img tag altogether and use this:

    <?php
    the_post_thumbnail( 'jumbo_thumbnail', array(
        'alt' => 'Responsive image',
        'class' => 'img-responsive'
    ) );
    ?>
    

    the_post_thumbnail function will output the img tag for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面