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['medium'] 中看到的那样,这就是我想要回显这个锚标签的方式,但不幸的是它没有返回中等大小,我也需要帮助来获得中等大小。下面是我得到的数组,你只能清楚地看到 [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
)
4

1 回答 1

2

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 }

    }
?>

所有可用的功能都记录在这里

PS:我是插件的作者。

于 2014-07-20T17:36:37.607 回答