schnti/photoswipe 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

schnti/photoswipe

Composer 安装命令:

composer require schnti/photoswipe

包简介

A plugin for Kirby CMS to intecrate photoswipe

README 文档

README

A plugin for Kirby CMS that adds photoswipe v5.

As of PhotoSwipe version v5, the integration of PhotoSwipe has become much easier. The Kirby plugin is only needed if the PhotoSwipe tag is required. Otherwise it is recommended to integrate PhotoSwipe without this plugin: https://photoswipe.com/v5/docs/getting-started/

Commercial Usage

This plugin is free but if you use it in a commercial project please consider

Installation

Download

Download the files and place them inside site/plugins/photoswipe.

Git Submodule

You can add the plugin as a Git submodule.

$ cd your/project/root
$ git submodule add https://github.com/schnti/kirby-photoswipe.git site/plugins/photoswipe
$ git submodule update --init --recursive
$ git commit -am "Add Kirby PhotoSwipe plugin"

Run these commands to update the plugin:

$ cd your/project/root
$ git submodule foreach git checkout master
$ git submodule foreach git pull
$ git commit -am "Update submodules"
$ git submodule update --init --recursive

Composer

composer require schnti/photoswipe

Install PhotoSwipe

npm install --save photoswipe

JS

import PhotoSwipeLightbox from 'photoswipe/dist/photoswipe-lightbox.esm.js';
import PhotoSwipe from 'photoswipe/dist/photoswipe.esm.js';

// don't forget to include CSS in some way
// import 'photoswipe/dist/photoswipe.css';

const lightbox = new PhotoSwipeLightbox({
  gallery: '.photoswipe',
  children: 'a',
  pswpModule: PhotoSwipe
});
lightbox.init();

CSS/SCSS

@import "~photoswipe/src/photoswipe.css";

Add static gallery

<div class="photoswipe">
    <figure>
        <a href="large-image.jpg" data-pswp-width="800" data-pswp-height="600" target="_blank">
            <img src="small-image.jpg" alt="Image description" />
        </a>
        <figcaption>Image caption</figcaption>
    </figure>
</div>

or add dynamic gallery with kirby markup (and Bootstrap 5 Grid)

<div class="row photoswipe">
    <?php foreach ($page->images() as $image): ?>

        <?php $pic = $image->resize(2000, null, 90); ?>

        <figure class="col-4">
            <a href="<?= $pic->url(); ?>"
               data-pswp-width="<?= $pic->width(); ?>"
               data-pswp-height="<?= $pic->height(); ?>"
               target="_blank">
                <img class="img-fluid" src="<?= $image->crop(600, 380, 80)->url(); ?>" alt="<?= $image->alt()->kirbytextinline() ?>"/>
            </a>

            <figcaption><?= $image->alt()->kirbytextinline() ?></figcaption>
        </figure>

    <?php endforeach; ?>
</div>

or use the photoswipe kirbytag

(photoswipe: image.jpg
    width: 200
    height: 200
    quality: 70
    crop: true
)

Tag Attributes

Small preview thumb

  • width: Integer (thumbnail resize width, default: 500)
  • height: Integer (thumbnail resize height, default: null)
  • quality: Integer (jpeg quality from 0 to 100, default: 80)
  • crop: Boolean (enable cropping the file according to the given width and height parameters, default: false)

Large lightbox image

  • lightboxwidth: Integer (image resize width, default: 1000)
  • lightboxheight: Integer (image resize height, default: null)
  • lightboxquality: Integer (jpeg quality from 0 to 100, default: 90)

Options

You can change the default gallery css selector width in /site/config/config.php:

return [
  'schnti.photoswipe.class' => 'photoswipe',
];

schnti/photoswipe 适用场景与选型建议

schnti/photoswipe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 555 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「kirby」 「kirby-plugin」 「kirby-cms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 schnti/photoswipe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 schnti/photoswipe 我们能提供哪些服务?
定制开发 / 二次开发

基于 schnti/photoswipe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 555
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 10
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-24