我創建了按類別ID獲取文章縮略圖的函數。 這是代碼:設置WordPress縮略圖文章的大小
<div class="row text-center">
<?php
foreach ($wp_query->posts as $single_post)
{
$single_post_ID = $single_post->ID;
$url = wp_get_attachment_url(get_post_thumbnail_id($single_post_ID, 'medium'));
?>
<div class="col-md-3 col-sm-6 hero-feature">
<div class="thumbnail">
<img src="<?php echo $url ?>" />
<div class="caption">
<h2><?php echo get_the_title($single_post_ID); ?></h2>
<p>
<a href="#" class="btn btn-primary">Commander</a>
<a href="#" class="btn btn-default">Plus Info</a>
</p>
</div>
</div>
</div>
<?php } ?>
</div>
我想與WordPress的功能設置大拇指800像素的大小500像素。
謝謝
這不是一個WordPress的功能做這樣問。如果你想在響應容器等圖像上使用100%的寬度,這是一個很好的解決方案。但是如果設計是靜態的,那麼爲什麼圖像要大一些呢? – 2014-12-05 15:26:28
包含的元素已經有一個給定的寬度,所以圖像不會超過800像素 – 2014-12-05 15:28:02
是的,它會工作,但真正的圖像將被加載,它會更大,然後需要。如果響應速度更快,但如果沒有,則可以製作多種圖像大小以使頁面負載更輕,這是非常有用的。想象一下,100 +的圖像縮略圖太大了,沒有空... – 2014-12-05 15:29:19