Yii2:如何在blueimp Gallery中将图像url作为数组传递

时间:2016-04-13 19:44:39

标签: php yii yii2

<!-- Carousel -->
<?php
foreach ($todo as $key => $row) {
foreach (explode(';', rtrim($row['images'], ';')) as $key_img => $value_img) {
$items[] = ['url' => $value_img, 'src' => $value_img];
}
}
?>
<div class="products_inside_wrapper intro_wrapper">
<div class="classes_inside_item bordered_wht_border">
<?php echo dosamigos\gallery\Gallery::widget(['items' => $items]); ?>
</div>
</div>
<!-- Carousel End -->

使用2amigos gallary小部件,我没有得到图像。请让我知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

我刚重新格式化以获得更好的阅读(缺少一个;)

import org.specs2.mutable.Specification
import test.Tag

@Tag(name = "database")
class MySpec extends Specification ...

并确保$ value_img中有适当的值(尝试var_dump)

我认为你还需要一个

<!-- Carousel -->
<div class="products_inside_wrapper intro_wrapper">
<div class="classes_inside_item bordered_wht_border">                                        
<?php 
    foreach ($todo as $key=>$row){
        foreach (explode(';',rtrim($row['images'],';')) as $key_img => $value_img) {
            $items[] = ['url' => $value_img, 'src' => $value_img];

        }
    }
?>                                            
</div>
<?php echo dosamigos\gallery\Gallery::widget(['items' => $items]); ?>
</div>
<!-- Carousel End -->

适当的价值

在bluimp doc中我找到了

 src' => 'yuor_path_for_src_image' 

您可以在其中查看<?php $items = [ [ 'url' => 'http://farm8.static.flickr.com/7429/9478294690_51ae7eb6c9_b.jpg', 'src' => 'http://farm8.static.flickr.com/7429/9478294690_51ae7eb6c9_s.jpg', 'options' => array('title' => 'Camposanto monumentale (inside)') ], url的值,在很多情况下,这些是完整图像和小图片的单独路径..