amkdev/server-files
Composer 安装命令:
composer require amkdev/server-files
包简介
Craft CMS plugin to retrieve a list of files based on a specified webroot path and extracts file information.
README 文档
README
Server Files for Craft CMS 3.x
Retrieve a list of files based on a specified folder path and extracts file information (optionally, currently onyl Exif image data)
Installation
To install the plugin, follow these instructions.
- Open your terminal and go to your Craft project:
cd /path/to/project
- Then tell Composer to load the plugin:
composer require amkdev/server-files
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Server Files.
Introduction
This little plugin retrieves a list of files based on a specified folder path.
This might be useful to you if
- You're running Craft 3.1 or above
- You need to retrieve files plus file information, not managed by Craft CMS, from a folder on your web server and return the output in Twig
Examples
Output the jpg files of a directory and the Exif data title and caption
Inside /uploads/images there are 3 image files:
22 Apr 22:54 image01.jpg
22 Apr 22:54 image02.jpg
22 Apr 22:54 icon.gif
In our Twig templates we set variables and give the server files a folder path for the search (required) and define (optionally) the information we need and regex pattern:
{% set settings =
{
path: 'uploads/images',
pattern: '*.jpg',
info: 'exif[title,caption]'
}
%}
{% set images = craft.serverfiles.config(settings) %}
{% for image in images %}
<img src="{{ image.file }}"
alt="{{ image.name }}"
title="{{ image.info.exif.title }}"
data-caption="{{ image.info.exif.caption }}">
{% endfor %}
Additionally you can use "full" {{ image.full }} to get the absolute path of a file.
This example Twig code would output:
<img src="/uploads/images/image01.jpg"
alt="image01.jpg"
title="Flower"
data-caption="A beautiful flower below the tree.">
<img src="/uploads/images/image02.jpg"
alt="image02.jpg" title="Tree"
data-caption="A tree in a field of flowers.">
If none of the configured Exif information is present, an empty string is returned for the data.
Disclaimer
This plugin is distributed free of charge under the MIT License. The author is not responsible for any data loss or issues resulting from use of the plugin.
Special Thanks
This plugin is based on GetFiles by You & Me Digital. Thanks for the simple and easy starting base.
Additionally this plugin uses PHPExif by Tom Van Herreweghe.
amkdev/server-files 适用场景与选型建议
amkdev/server-files 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「files」 「list」 「Craft」 「craftcms」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 amkdev/server-files 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amkdev/server-files 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 amkdev/server-files 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An HTML5 upload field for the CMS and frontend forms.
Easily provide front-end sorting controls for SilverStripe lists
A block to display a list of links to child pages, or pages in current level
GraphQL authentication for your headless Craft CMS applications.
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
Set Links with a specific language parameter
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-10