Installs: 2 015

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 4

Forks: 5

Open Issues: 0


3.0.1 2021-07-16 08:53 UTC

This package is auto-updated.

Last update: 2021-09-16 12:04:27 UTC


An extension to SilverStripe's Image class to integrate with the TinyPNG API.


With composer:

composer require kinglozzer/silverstripe-tinypng ^3.0


Add your TinyPNG API key to your _config.yml:

  tinypng_api_key: 'xxxx_yyyy_zzzz'

Add the Compressed method to your templates when outputting images:

{$Image.CroppedImage(150, 300).Compressed}

NOTE: Compressed must be the last modification you call on your image - otherwise you’ll compress an image, then resample it again afterwards, potentially undo-ing the compression.

If you set an invalid API key, or exceed your monthly API allowance, then a warning will be shown in dev/test mode. In live mode compression will (intentionally) silently fail and output the un-compressed image, but will still log a message via the Logging API.