2014-07-19 165 views
1

我使用動態特色圖像並將多個產品圖像添加到單個自定義帖子類型名稱作爲單個產品的產品,但我試圖在我的模板中獲取這些圖像,但陣列只返回我只有兩個尺碼[拇指] [全],但我需要媒體以及下面是我的代碼插圖中的中等大小的圖像稱爲動態特色圖像

<?php 

    if(class_exists('Dynamic_Featured_Image')) { 
    global $dynamic_featured_image; 

    $featured_images = $dynamic_featured_image->get_featured_images(); 

    foreach($featured_images as $featured_image) { 

?> 
    <a href="<?php echo $featured_image['full'];?>" rel="rings" rev="<?php echo $featured_image['medium'];?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a> 
<?php } 

    } 
?> 

正如你們可以在錨標記$ featured_image參見[「中」]這是怎麼了我想要回顯這個錨定標記,但不幸的是,它不會返回中等大小,而且我也需要獲得中等大小的幫助。下面是我得到的數組,只有[thumb]和[full]才能清楚地看到。請幫忙

Array 
(
    [thumb] => http://www.example.com/wp-content/uploads/2014/07/product-1-120x90.jpg 
    [full] => http://www.example.com/wp-content/uploads/2014/07/product-1.jpg 
    [attachment_id] => 254 
) 
+0

在一個小時內我的問題被查看了兩次,沒有人可以查看和回覆。 – user52735

回答

1

您需要通過致電get_image_url函數得到中等大小的圖像。試試這個:

<?php  
    if(class_exists('Dynamic_Featured_Image')) { 
    global $dynamic_featured_image; 

    $featured_images = $dynamic_featured_image->get_featured_images(); 

    foreach($featured_images as $featured_image) { 
      $mediumSizedImage = $dynamic_featured_image->get_image_url($featured_image['attachment_id'], 'medium');  
       echo "<img src = '" . $mediumSizedImage . "' />"; 
     ?> 
     <a href="<?php echo $featured_image['full'];?>" rel="rings" rev="<?php echo $mediumSizedImage ?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a> 
    <?php } 

    } 
?> 

所有可用的功能都記錄在案here

PS:我是pluginauthor