powerkernel/ yii2-photoswipe
Yii2的PhotoSwipe扩展
1.1.5
2017-12-01 14:03 UTC
Requires
- bower-asset/photoswipe: ~4.1.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-16 20:26:41 UTC
README
Yii2的PhotoSwipe扩展
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一
php composer.phar require --prefer-dist powerkernel/yii2-photoswipe "*"
或者将以下内容添加到你的composer.json
文件的require部分。
"powerkernel/yii2-photoswipe": "*"
使用方法
扩展安装完成后,只需在代码中使用即可
添加画廊
<?= \powerkernel\photoswipe\Gallery::widget([ 'items' => [ [ 'image' => 'https://c2.staticflickr.com/2/1518/24267732553_54aed33368_b.jpg', 'title' => 'Image Title 1', 'caption' => 'Caption 2', 'size' => '1024x685', 'thumb' => 'https://c2.staticflickr.com/2/1518/24267732553_54aed33368_m.jpg', ], [ 'image' => 'https://farm6.staticflickr.com/5023/5578283926_822e5e5791_b.jpg', 'title' => 'Image Title 2', 'caption' => 'Caption 3', 'size' => '1024x768', 'thumb' => 'https://farm6.staticflickr.com/5023/5578283926_822e5e5791_m.jpg', ], ] ]) ?>
为页面上的现有图像启用灯箱效果
<?php echo \powerkernel\photoswipe\Modal::widget([ 'selector'=>'.lightbox', 'images' => [ [ 'src' => 'https://c2.staticflickr.com/2/1518/24267732553_54aed33368_b.jpg', 'width' => 1024, 'height' => 685, 'alt' => 'Title 1', ], [ 'src' => 'https://farm6.staticflickr.com/5023/5578283926_822e5e5791_b.jpg', 'width' => 1024, 'height' => 768, 'alt' => 'Title 2', ], ] ]); ?>