定制 nerdcel/kirby3-responsive-images 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

nerdcel/kirby3-responsive-images

最新稳定版本:v3.4.1

Composer 安装命令:

composer require nerdcel/kirby3-responsive-images

包简介

Kirby3 plugin to manage responsive images settings using the panel.

README 文档

README

GitHub release License Kirby 4+

Responsive Images Plugin

This plugin provides functionality to generate responsive images in your Kirby CMS projects.

Installation

  1. Using Composer:
    composer require nerdcel/kirby3-responsive-images
  2. Manually: Download the latest release and copy the contents of the into your site/plugins/responsive-images folder.

Configuration

You can configure the plugin by adding the following options to your config.php file. Consider using the "ready" hook inside the kirby config if you are calling the kirby() function to set the configPath.

'ready' => function ($kirby) {
    return [
        'nerdcel.responsive-images' => [
            'configPath' => kirby()->root('content'),
            'configFile' => 'responsive-img.json',
            'quality' => 75,
            'defaultWidth' => 1024,
            'allowedRoles' => ['admin'],
        ],
    ];
}

If you open the panel now, the plugin should have generated an empty json file with the following content:

{"breakpoints": [], "settings": []}

Usage

Generating Responsive Images To generate a responsive image, use the makeResponsiveImage method:

use Nerdcel\ResponsiveImages\ResponsiveImages;
use Kirby\Cms\File;

$responsiveImages = ResponsiveImages::getInstance();
$imageTag = $responsiveImages->makeResponsiveImage(
    'settings-slug',
    $file, // instance of Kirby\Cms\File
    'custom-classes',
    true, // lazy loading
    'Alt text',
    'webp'
);

echo $imageTag;

But there is also a helper function that you can use to generate responsive images:

echo responsiveImage('settings-slug', $file, 'custom-classes', true, 'Alt text', 'webp');

Focal Point

You can set the focal point(s) of an image for different viewports by adding the following fields to the image file blueprint:

...
fields:
  focalpoints:
    label: Focal Points override
    type: focalpoints

Focal points

License This plugin is licensed under the MIT License. See the LICENSE file for more details.

统计信息

  • 总下载量: 2.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固