poznet / imageoptimbundle
Symfony Bundle - Wrapper for tinyjpg
Requires
- php: >=5.3
- tinify/tinify: ^1.1.1
This package is auto-updated.
Last update: 2024-12-13 23:52:01 UTC
README
Bundle for Symfony 2/3
Main idea is to use tinify API to shrink images, that are already stored in server. Shrinking when uploading images takes too much time, so it's better to do that with commands firedup in cron
Usage
Bundle adds new commands (for use with cron for example):
console image:optim:scan
- searches for images in given dirs
console image:optim:minify
- minify images (default is 20 images per 1 run - can be overwriten by argument)
console image:optim:stats
- writes statistics info
console image:optim:truncate
- removes all images data from database
Installation
Install with composer
composer require poznet/imageoptimbundle
create databes structures
console d:s:u --force
Add API key in parameters.yml
tinifyAPI: key
Define paths in parameters.yml All paths should be realive to main all dir (1 above app).
This parameters are used in Finder() Component as in() and exclude()
imageoptim_dirs:
- web/media
- web/media2
imageoptim_excluded:
- cache
Other
Bundle uses custom events , so it can be easily extended
Events :
- image.add
- image.minify
Both takes Poznet\ImageOptimBundle\Event\ImageEvent class as event.