Skip to content

Commit

Permalink
Beef up README
Browse files Browse the repository at this point in the history
  • Loading branch information
bradt committed Dec 12, 2016
1 parent 79e124d commit 85cba18
Showing 1 changed file with 60 additions and 3 deletions.
63 changes: 60 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
# Image Processing Queue

An alternative to on-the-fly image processing. Like on-the-fly image processing, it allows theme developers to define image sizes specifically for certain contexts to greatly reduce the number of resized images and hence reduce disk space usage. The difference from on-the-fly image processing is that when an image size doesn't exist yet, it immediately returns the closest size as the `src` and all available sizes of the same aspect ratio in the `srcset` and adds the image size to a queue to be generated in the background as server resources allow.
Image Processing Queue is an alternative to on-the-fly (OTF) image processing (e.g. [Aqua Resizer](https://github.com/syamilmj/Aqua-Resizer)) for WordPress themes.

Like OTF image processing, it allows theme developers to define image sizes for specific theme contexts rather than defining a size for all uploaded images. This greatly reduces the number of resized images and hence reduces disk space usage and the wait time when uploading an image.

Image Processing Queue differs from OTF image processing in how it behaves when an image doesn't exist yet. OTF generates the image right away and the end-user has to wait for the image to be generated. With Image Processing Queue there's no waiting. It immediately returns an image that already exists (that is the closest fit to the image size requested) and adds the image size to a queue to be generated in the background as server resources allow. Typically the images are generated right away and will be available for the next request.

Image Processing Queue also accommodates responsive themes much better than OTF. It allows theme developers to define a list of image sizes that will work best for their theme's responsive breakpoints. Images generated by Image Processing Queue are added to the post meta so that WordPress core's responsive functions will automatically add them to the `srcset` and delete them from the filesystem when the image is deleted from the Media Library.

## Installation
## Installation

### Install as a Plugin

To install Image Processing Queue as a plugin, clone this repository to `image-processing-queue` in your WordPress plugins folder and run `composer install`.

```
$ cd /path/to/wordpress/wp-content/plugins/
$ git clone git@github.com:deliciousbrains/wp-image-processing-queue.git image-processing-queue
$ composer install
```

### Install as a Theme Library

If you're a theme developer and would like to include Image Processing Queue as a library in your theme, you'll need to clone this repository into your theme:

```
$ cd /path/to/wordpress/wp-content/themes/your-theme/
$ git clone git@github.com:deliciousbrains/wp-image-processing-queue.git image-processing-queue
$ composer install
```

You'll also need to add the following to your functions.php file:

```php
require_once TEMPLATEPATH . '/image-processing-queue/vendor/a5hleyrich/wp-background-processing/classes/wp-async-request.php';
require_once TEMPLATEPATH . '/image-processing-queue/vendor/a5hleyrich/wp-background-processing/classes/wp-background-process.php';
require_once TEMPLATEPATH . '/image-processing-queue/includes/class-ipq-process.php';
require_once TEMPLATEPATH . '/image-processing-queue/includes/class-image-processing-queue.php';
require_once TEMPLATEPATH . '/image-processing-queue/includes/ipq-template-functions.php';

Image_Processing_Queue::instance();

```

## Usage

When you want to output an image in your theme, simply call the `ipq_get_theme_image()` function passing in the ID of the image post, an array of sizes you've decided on for the image in this particular context, and an array of additional HTML attributes for the `<img>` tag:

```php
echo ipq_get_theme_image( $post_id, array(
array( 600, 400, false ),
array( 1280, 720, false ),
array( 1600, 1067, false ),
),
array(
'class' => 'header-banner'
)
);
```

## License

Clone repository to your WordPress plugins folder and run `composer install`
[GPLv2+](http://www.gnu.org/licenses/gpl-2.0.html)

0 comments on commit 85cba18

Please sign in to comment.