定制 kaiseki/wp-image-sizes 二次开发

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

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

kaiseki/wp-image-sizes

Composer 安装命令:

composer require kaiseki/wp-image-sizes

包简介

Register, configure and remove WordPress image sizes, including aspect-ratio-based size sets

README 文档

README

Register, configure and remove WordPress image sizes, including aspect-ratio-based size sets.

Driven by the image_sizes config key and wired through ConfigProvider: set the built-in size dimensions, register custom sizes, generate whole families of sizes from an aspect ratio and a list of widths, tune the big-image threshold, and remove unwanted core sizes.

Installation

composer require kaiseki/wp-image-sizes

Requires PHP 8.2 or newer.

Usage

Register ConfigProvider with your laminas-style config aggregator and configure the image_sizes key:

use Kaiseki\WordPress\ImageSizes\AspectRatio;
use Kaiseki\WordPress\ImageSizes\ImageSize;

return [
    'image_sizes' => [
        // Built-in sizes: [width, height, crop] or null to leave untouched.
        'thumbnail'    => [150, 150, true],
        'medium'       => [300, 300, false],
        'medium_large' => null,
        'large'        => [1024, 1024, false],

        // Additional custom sizes.
        'image_sizes' => [
            new ImageSize('hero', 1600, 900, true),
        ],

        // Generate one ImageSize per width from a name + aspect ratio.
        'aspect_ratios' => [
            (new AspectRatio('card-', 4, 3, []))->withWidths(320, 640, 960),
        ],

        // Override the 2560px "big image" threshold (or false to disable scaling).
        'big_image_threshold' => 2560,

        // Core/registered sizes to remove.
        'remove_sizes' => ['1536x1536', '2048x2048'],
    ],
];

ConfigProvider registers factories for WpImageSizes (applies the size configuration), ImageSizesRegistry, BigImageSizeThreshold (the big_image_size_threshold filter) and RemoveImageSizes (removes sizes and filters them out of intermediate_image_sizes). An AspectRatio expands a ratio and a set of widths into individual ImageSizes via createImageSizes().

Development

composer install
composer check   # check-deps, cs-check, phpstan

License

MIT — see LICENSE.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固