dongsibao8977 2015-12-13 16:46
浏览 15
已采纳

缩略图的强制大小

I'm trying to put constant image size for post thumbnail in my site. (no matter whats the size of the original image, the image should scale for the constant size). I try this:

<?php if (has_post_thumbnail())  the_post_thumbnail(array(400, 200)); ?>

But then I got this in my site:

<img width="356" height="200" src="http://localhost/mida/wp-content/uploads/2015/07/תמוננ-מ.jpg" class="attachment-400x200 wp-post-image" alt="תמוננ מ">

The width and height are different then what I put.

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • duancaishi1897 2015-12-13 16:54
    关注

    Why don't you just use CSS? Find the lass that is used on the thumbnails (with yourbrowsers developer tool) and apply the desired size to that class:

    .the_thumbnail_class img {
         width: 400px;
         height: 200px;
    }
    

    (note: that class name is only a guess)

    however, keep in mind that images that don't have a width/heigth proportion of 2:1 will be distorted that way, so it's better so write this:

    .the_thumbnail_class img {
         height: 200px;
         width: auto;
    }
    

    that way they will all have the same height, the width will adust automatically, keeping the proportions intact.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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