Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Just in Time Image Manipulation for Symphony CMS
PHP JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lang
lib
LICENCE
README.markdown
extension.driver.php

README.markdown

JIT Image Manipulation

"Just in time" image manipulation for Symphony. It is part of the Symphony core download package.

Synopsis

A simple way to manipulate images on the fly via the URL. Supports caching, image quality settings and loading of offsite images.

Installation

Information about installing and updating extensions can be found in the Symphony documentation at http://symphony-cms.com/learn/.

Updating

Due to some .htaccess changes in Symphony 2.0.6+, it is recommended that you edit your core Symphony .htaccess to remove anything before 'extensions/' in the JIT rewrite. It should look like the following regardless of where you installed Symphony:

### IMAGE RULES
RewriteRule ^image\/(.+\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

It is not absolutely necessary to do this, but may prevent problems with future releases.

Usage

Basics

The image manipulation is controlled via the URL, e. g.:

<img src="{$root}/image/2/80/80/5{image/@path}/{image/filename}" />

The extension accepts four numeric settings for the manipulation:

  1. mode
  2. width
  3. height
  4. reference position (for cropping only)

There are four possible modes:

  • 0 none
  • 1 resize
  • 2 resize and crop (used in the example)
  • 3 crop

If you're using mode 2 or 3 for image cropping you need to specify the reference position:

+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 7 | 8 | 9 |
+---+---+---+

If you're using mode 2 or 3 for image cropping, there is an optional fifth background color setting. This can accept shorthand or full hex colors.

  • For Jpeg images, it is advised to use this if the crop size is larger than the original, otherwise the extra canvas will be black.
  • For transparent Png or Gif images, supplying the background color will fill the image. This is why the setting is optional

The extra fifth setting makes the url look like this:

<img src="{$root}/image/2/80/80/5/fff/{image/@path}/{image/filename}" />
  • If you wish to crop and maintain the aspect ratio of an image but only have one fixed dimension (that is, width or height), simply set the other dimension to 0

Trusted Sites

In order pull images from external sources, you must set up a white-list of trusted sites. To do this, goto "System > Preferences" and add rules to the "JIT Image Manipulation" rules textarea. To match anything use a single asterisk (*).

Change Log

Version 1.12

  • Fixes issue where cached images would be delivered even though the original file was removed (thanks @michael-e)
  • Fixes direct display mode (thanks @michael-e)
  • Output errors and correctly set 404 headers when things go wrong

Version 1.11

  • Allow external images to be cached (thanks @michael-e)
  • Fixes PNG and GIF transparency issues (thanks to @designermonkey)
  • Background color on crop becomes optional

Version 1.10

  • Compatibility with Symphony 2.2

Version 1.09

  • Sending ETag header with response
  • Added support for HTTP_IF_MODIFIED_SINCE and HTTP_IF_NONE_MATCH request headers, which will mean a 304 Not Modified header can be set (Thanks to Nick Dunn for helping on this one)
  • Added Portuguese and Italian translations (Thanks to Rainer Borene & Simone Economo for those)

Version 1.08

  • Added French localisation
  • Adjusted German localisation
  • Fixed a Symphony 2.0.7RC2 compatibility issue.

Version 1.07

  • Added localisation files for Dutch, German, Portuguese (Brazil) and Russian
  • trusted() will look for the jit-trusted-sites before attempting to return its contents. This prevents warnings from showing up in the logs.

Version 1.06

  • Code responsible for .htaccess update will no longer try to append the rewrite base to for path to extensions folder

Version 1.05

  • Fixed bug introduced by usage of the imageAntiAlias() function
  • Errors and warnings are logged in the main Symphony log
  • A dump of internal params are logged in addition to any errors

Version 1.04

  • Adding support for alpha masked images.

Version 1.03

  • Minor changes to how DOCROOT` is determined

Version 1.02

  • Disabling extension will remove rule from .htaccess

Version 1.01

  • Updated to work with 2.0.2 config changes
Something went wrong with that request. Please try again.