定制 ceceppa/meno 二次开发

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

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

ceceppa/meno

Composer 安装命令:

composer require ceceppa/meno

包简介

A WordPress Library to keep small your upload folder

README 文档

README

Prevents WordPress from polluting your upload folder with big images and countless resized versions.

WordPress generates, by default, three resized version for each image uploaded. On top of that creates additional ones for each custom image size defined using add_image_size. All of that regardless of the fact that the image size is used or not!

Also, WordPress does allow a user to upload and use huge images

So, this leads quickly to a huge upload folder, even for a quite small website.

Meno prevents WordPress from creating any resized version unless you need it! It also prevents users from uploading and using huge images.

Example

Suppose we define two new image sizes called home-tile and full-width:

add_image_size( 'home-tile', 450, 253, true );
add_image_size( 'full-width', 1440, 810, true );

Using this class, when the user uploads an image, the upload folder will look like:

|- example.jpg
|- example.jpg.original*

Nothing than the original image is there!

The .original file

We know, users like to use huge images, sometimes more than 1Mb. So, anytime a user uploaded an image bigger than that, Meno will resize it using a defined MAX_WIDTH and MAX_HEIGHT.

By default the max size defined is 1920x1080, you can override this by defining:

define( 'MENO_MAX_WIDTH', ...);
define( 'MENO_MAX_HEIGHT', ...);

Habemus resized version

So, when does a resized version is created?

Simple, when it's used, for example:

the_post_thumbnail( 'home-tile' )

In this case, and only this case, Meno will check if the 450x253 size exists, and if not, it will generate it on the fly!

How meno is different from other solutions?

Beside Meno, we have two options to prevent the issue:

  • Re-define the size of thumbnail and medium sizes
  • Use Image Optimizer plugins

The re-defining issue

I do personally don't like this option at all! Because even changing the default sizes for thumbnail and medium, those names don't make sense to me. Because on some website I might have/need thumbnails with a different ratio. And, for me, medium is too generic doesn't mean anything specific! And I prefer my naming for the image sizes.

Image Optimizer

There are several plugins to do the job, and all of them will optimise the main image and the resized ones, to reduce the size of the upload folder.

They work quite well, but have the same issue: all the resized versions are generated regardless of the fact that you use them or not!

Getting Started

Installing

Manually

Download the repository and load the meno.php file within your theme or plugin.

Composer

composer require ceceppa/meno --dev

Usage

prevent_generation();

Running the tests

To run all replace your database info inside the run-tests.sh file first.

To set up and installs the WordPress testing library first and run all the tests:

composer test

To run the PHPUnit tests only:

composer phpunit

To analyse the code quality:

composer phpinsights

Deployment

WordPress coding standards are used with few exceptions.

BUGS

At the moment in Gutengerg you can only choose the Large size.

TODO

  • [ ] Allow user to choose different image sizes in Gutenberg

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

  • Alessandro Senese - Initial work - Ceceppa

License

This project is licensed under the MIT License - see the LICENSE.md file for details

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固