定制 vaersaagod/assetmate 二次开发

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

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

vaersaagod/assetmate

Composer 安装命令:

composer require vaersaagod/assetmate

包简介

Protect your assets, mate!

README 文档

README

Protect your assets, mate!

Screenshot

Requirements

This plugin requires Craft CMS 5.0.0+ and PHP 8.2+.

Installation

To install the plugin, follow these instructions:

  1. Install with composer via composer require vaersaagod/assetmate from your project directory.
  2. Install the plugin in the Craft Control Panel under Settings → Plugins, or from the command line via ./craft install/plugin assetmate.

Configuring

AssetMate can be configured by creating a file named assetmate.php in your Craft config folder, and overriding settings as needed.

<?php

use craft\elements\Asset;

return [
    'volumes' => [
        '*' => [
            'validation' => [
                'size' => [
                    'max' => '20M',
                ]
            ]
        ],
        'images' => [
            'validation' => [
                'extensions' => ['gif', 'jpg', 'jpeg', 'png'],
                'size' => [
                    'max' => '2M',
                ],
                'dimensions' => [
                    'maxWidth' => 2200, 
                    'maxHeight' => 2200,
                    'minWidth' => 200, 
                    'minHeight' => 200,
                ],
                'autoValidateResizeDimensions' => true,
            ],
            'resize' => [
                'maxWidth' => 2200,
                'maxHeight' => 2200,
                'quality' => 90,
            ],
            'convertUnmanipulable' => true,
        ],        
        'illustrations' => [
            'validation' => [
                'extensions' => ['svg'],
                'size' => [
                    'max' => '1M',
                    'min' => '50K',
                ]
            ]
        ],        
        'videos' => [
            'validation' => [
                'extensions' => ['mp4'],
                'size' => [
                    'max' => '12M',
                ],
            ],
        ],
    ]
];

Console commands

AssetMate adds a couple of asset-related CLI utility commands:

Purging "unused" assets

An "unused" asset is an asset that isn't a target in any element relations (i.e. has no source relations), and is also not found in any reference tags in database content tables (meaning it's not linked to or used in Redactor/CKEditor/LinkMate fields).

To delete all unused assets:

php craft assetmate/purge

Options

--volume (string, default '*')

Only purge assets in a specific volume, e.g. php craft assetmate/purge --volume=images

--kind (string, default '*')

Only purge assets with a specific file kind, e.g. php craft assetmate/purge --kind=image

--lastUpdatedBefore (string|int|bool, default 'P30D')

By default, AssetMate will not purge assets with a dateUpdated timestamp later than 30 days ago. This option can be set to an integer (i.e. number of seconds), a valid PHP date interval string, or false to disable the dateUpdated check entirely.

--searchContentTables (bool, default true)

In addition to checking the relations table for assets without any source element relations, AssetMate will search content tables to make sure that the assets found aren't referenced in text columns (e.g. in reference tags in Redactor or CK Editor). This can take a long time if there are a lot of assets and/or content, so if you're confident that you have no asset references in text fields, set this option to false to bypass content table searching altogether.

--searchContentTablesBatchSize (int, default 500)

After querying for assets without any source element relations, AssetMate will search for these assets across text columns in content tables. To speed up this lengthy process, the IDs are batched. If you're running into a PDO exception "Timeout exceeded in regular expression match", consider setting the batch size to a lower value.

--deleteEmptyFolders (bool, default true)

If true, AssetMate will scan for and delete any empty folders after purging unused assets. If the --volume option is used, only empty folders in that volume will be deleted.

Purging empty folders

An empty folder is a folder that doesn't contain any assets (or any sub folders that contain assets).

To delete all empty folders:

php craft assetmate/purge/folders

Options

--volume (string, default '*')

Only delete empty folders in a specific volume, e.g. php craft assetmate/purge/folders --volume=images

Price, license and support

The plugin is released under the MIT license. It's made for Værsågod and friends, and no support is given. Submitted issues are resolved if it scratches an itch.

Changelog

See CHANGELOG.MD.

Credits

Brought to you by Værsågod

Icon designed by Freepik from Flaticon.

vaersaagod/assetmate 适用场景与选型建议

vaersaagod/assetmate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.35k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 03 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-15