duanchuonong5370 2016-04-09 12:43
浏览 54

Yii2:没有获得Yii2的2amigos Gallery Widget中的所有图像

Im using 2amigos Gallery Widget for Yii2 to display images

<?php foreach ($img as $key=>$row): ?>
<div class="classes_inside_item bordered_wht_border">
<?php
foreach (explode(';',rtrim($row['images'],';')) as $key_img => $value_img)
{
?>
<?php
$images=[Yii::getAlias('@web').'/'.$value_img];
?>
<?php
}
?>
</div>
<?php echo dosamigos\gallery\Gallery::widget(['items' => $images]); ?>
<?php endforeach; ?>

By using above code im able to show only one image though it has 3 images in database (images path is saved in database path like /uploads/img1;/uploads/img2;/uploads/img3)

I need to first obtain all the path in array and then pass this array to Gallary Widget to show images

  • 写回答

1条回答 默认 最新

  • dongzaocheng3214 2018-09-20 20:30
    关注

    If this helps at all, I'm reading my images from a table into a collection and then looping them like this:

    $items = array();
    foreach ($cImages as $oImage) {
        $item = [
                    'url' => '/images/listingimages/' . $oImage->file_name,
                    'src' => '/images/listingimages/thumbs/' . $oImage->file_name,
                    'options' => array('title' => $oImage->name),
                ];
        $items[] = $item;
    }
    

    And then loading $items into the widget.

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录