Skip to Content search facebook instagram pinterest twitter youtube

On-the-fly image reisizing

If you need a specific image size, then use the File::resizeUrl method.

First argument is file id or filename.

Second argument is the size definition.

Size definitions

The format is:


The type, width, and height parameters are required, but the position and quality parameters (are optional).

Resize types

This is a single letter, either 'r', 'c' or 'm'

r = resize, up or down, try to fill the area requested

c = crop, resulting file will always be the width and height requested

m = resize down only

Width and height

These are in pixels.

Crops require both to be provided, but resizes can accept a 0 for either parameter (but not both) to auto-calculate.


For crops, the anchor position.

First letter is the X crop position, one of l or c or r for left, center, right

Second letter is the Y crop position, one of t or c or b for top, center, bottom.


This only aplies for jpeg images, and is a number between 0 (worst) and 100 (best)

Resize definition examples

Crop to 500px square

Crop to 300 wide by 600 tall, anchoring to the center-bottom of the image

Crop to 300 wide by 600 tall, anchoring to the center-top of the image, and saving at quality 70

Resize up or down to fit 750 wide by 250 tall

Resize down only to fit 500 square, and output at a quality of 50


Resized images are stored locally in a cache to improve performance.

Note that this means that using a given resize definition in multiple areas will give better performance.