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 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据