2014-10-09 23 views
0

我累了讓WordPress的特色圖片響應bootstrap。使圖像響應自舉的方法是如何使用Bootstrap使圖像響應並在wordpress上使用它?

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

動態顯示功能的圖像時,我厭倦了使用此方法在WordPress。

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

但它不工作。我知道,如果我把一個鏈接,而不是<?php the_post_thumbnail('jumbo_thumbnail'); ?>它會工作。但我正在動態獲取特色圖片,而此方法無效。

回答

1

你很近。獲得完全擺脫你img的標籤和使用:

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

the_post_thumbnail功能將輸出img標籤爲您服務。

+0

真棒,它的工作。謝謝。 – Lifestohack 2014-10-09 21:03:35

相關問題