joppuyo/unique-media-file-folders 问题修复 & 功能扩展

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

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

joppuyo/unique-media-file-folders

Composer 安装命令:

composer require joppuyo/unique-media-file-folders

包简介

Change the default WordPress upload folder structure to a randomly generated one

README 文档

README

Build Status Packagist

Change the default WordPress upload folder structure to a randomly generated one. Each image and its thumbnails will be given an unique folder with a randomly generated name.

Why?

Because WordPress default media file paths are not very good. You either get year-month folders which may look funny if you are re-using content and is reminiscent of WordPress' blogging engine roots. The other option is to put all files into one folder which does not scale when you start to have a lot of files.

Too many files in a folder can lead to performance issues on filesystems like EXT4. If all your files are in the same folder, you’ll also run into file name conflicts.

How it works

Instead of the following file paths:

https://example.com/wp-content/uploads/2019/01/photo.jpg
https://example.com/wp-content/uploads/2019/01/photo-150x150.jpg
https://example.com/wp-content/uploads/2019/01/photo-300x168.jpg

https://example.com/wp-content/uploads/2019/01/image.png
https://example.com/wp-content/uploads/2019/01/image-150x150.png
https://example.com/wp-content/uploads/2019/01/image-300x168.png

The plugin will generate the following paths:

https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo.jpg
https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo-150x150.jpg
https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo-300x168.jpg

https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image.png
https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image-150x150.png
https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image-300x168.png

How to install

  1. Download latest version from the Releases tab
  2. Unzip the plugin into your wp-content/plugins directory
  3. Activate Unique Media File Folders from your Plugins page

Customizing folder depth

By default, folder depth is 1 so every file will be given its own folder. Customize folder depth using umff_folder_depth filter. For example:

add_filter('umff_folder_depth', function() {
    return 4;
});

Will yield the following folder structure:

https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo.jpg
https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo-150x150.jpg
https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo-300x168.jpg

https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image.png
https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image-150x150.png
https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image-300x168.png

How are paths generated

For all of your files, first a UUID4 will be generated. It will then be encoded into Base36 which means it will contain characters from a to z and 0 to 9. This is used as the folder name. If folder depth option is greater than 1, first n characters of the UUID are used as subfolders.

Further reading

Structuring WordPress’ upload directory to handle lots of files - Ctrl blog

joppuyo/unique-media-file-folders 适用场景与选型建议

joppuyo/unique-media-file-folders 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 142 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 joppuyo/unique-media-file-folders 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 142
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-02-02