GithubHelp home page GithubHelp logo

isabella232 / wp-cubi-imagemin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from globalis-ms/wp-cubi-imagemin

0.0 0.0 0.0 46 KB

Standalone image minification WordPress plugin

Home Page: https://github.com/globalis-ms/wp-cubi-imagemin

License: GNU General Public License v2.0

PHP 100.00%

wp-cubi-imagemin's Introduction

wp-cubi-imagemin

Build Status Latest Stable Version License

Standalone image minification WordPress plugin

wp-cubi

Overview

wp-cubi-imagemin is a very simple image minification plugin for WordPress, meant to be used in a composer installation. It uses a couple of image minification tools to optimize uploaded images (jpg, png, gif and svg).

wp-cubi-imagemin is essentially a WordPress wrapper for psliwa/image-optimizer.

Installation

  • composer require globalis/wp-cubi-imagemin

Configuration

The plugin will try to find the image minification tools it needs on the system. But you can provide your own binaries instead, and the plugin will use them.

To use your own binaries, just define the following constants in your configuration files, pointing to your binaries paths :

define('WP_CUBI_IMAGEMIN_PATH_BIN_ADVPNG', '/var/www/your-project/bin/advpng');
define('WP_CUBI_IMAGEMIN_PATH_BIN_GIFSICLE', '/var/www/your-project/bin/gifsicle');
define('WP_CUBI_IMAGEMIN_PATH_BIN_JPEGOPTIM', '/var/www/your-project/bin/jpegoptim');
define('WP_CUBI_IMAGEMIN_PATH_BIN_JPEGTRAN', '/var/www/your-project/bin/jpegtran');
define('WP_CUBI_IMAGEMIN_PATH_BIN_OPTIPNG', '/var/www/your-project/bin/optipng');
define('WP_CUBI_IMAGEMIN_PATH_BIN_PNGCRUSH', '/var/www/your-project/bin/pngcrush');
define('WP_CUBI_IMAGEMIN_PATH_BIN_PNGOUT', '/var/www/your-project/bin/pngout');
define('WP_CUBI_IMAGEMIN_PATH_BIN_PNGQUANT', '/var/www/your-project/bin/pngquant');
define('WP_CUBI_IMAGEMIN_PATH_BIN_SVGO', '/var/www/your-project/bin/svgo');

If you do not define one ot the binaries paths, the plugin will try to use the system version. If it doesn't find an installed version on the system, it will just skip this tool and use the other ones.

You don't need to have all the tools working, but it is recommanded to have at least pngquant, jpegoptim and gifsicle to provide a meaningfull level of minification.

Note: binary files must have execution permissions.

Hooks

  • apply_filters('wp-cubi-imagemin\options', $options) : Filter the options of ImageOptimizer\OptimizerFactory (see the complete list), such as the JPG compression level (default to 85 in wp-cubi-imagemin).

  • apply_filters('wp-cubi-imagemin\custom_logger', null)) : Allow to provide a custom logger that implements Psr\Log\LoggerInterface. If no custom logger is provided, inpsyde/wonolog will be used if available.

  • apply_filters('wp-cubi-imagemin\wonolog_channel', \Inpsyde\Wonolog\Channels::DEBUG) : Filter inpsyde/wonolog log channel.

Bulk optimization

Bulk image optimization can be done using wp-cli :

  • Install wp-cli and ensure wp-cubi-imagemin is activated
  • Usage: wp media optimize <directories>... [--jpeg_level=<jpeg_level>]
  • Help: wp help media optimize

Note: thumbnails regeneration commands such as wp media regenerate will trigger plugin optimization functions as well.

Binaries

Available binaries :

wp-cubi-imagemin's People

Contributors

pierre-dargham avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.