modernkernel/yii2-photoswipe

该软件包已被放弃,不再维护。作者建议使用 powerkernel/yii2-photoswipe 软件包。

Yii2 的 PhotoSwipe 扩展

安装数量: 3,609

依赖项: 0

建议者: 0

安全: 0

星标: 5

关注者: 3

分支: 8

类型:yii2-extension

1.1.5 2017-12-01 14:03 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:00:10 UTC


README

Yii2 的 PhotoSwipe 扩展

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一

php composer.phar require --prefer-dist powerkernel/yii2-photoswipe "*"

或者将以下内容添加到您的 composer.json 文件的要求部分。

"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',
                ],
            ]
    ]);
?>