kollarovic / thumbnail
Generating image thumbnails
Installs: 26 582
Dependents: 2
Suggesters: 0
Security: 0
Stars: 10
Watchers: 5
Forks: 16
Open Issues: 1
Requires
- php: >=8.0
- latte/latte: ^3.0
- nette/application: ^3.0
- nette/bootstrap: ^3.0
- nette/http: ^3.0
- nette/utils: ^3.0 || ^4.0
Requires (Dev)
- mockery/mockery: ~1.0
- nette/tester: ~1.3
This package is auto-updated.
Last update: 2024-09-17 09:07:52 UTC
README
{var $image='images/image.jpg'} <img src="{$image|thumbnail: 150, 150}" />
Installation
composer.json
composer require kollarovic/thumbnail
config.neon
extensions: thumbnail: Kollarovic\Thumbnail\DI\Extension
Configuration
config.neon
thumbnail: thumbPathMask: 'images/thumbs/{filename}-{width}x{height}.{extension}' placeholder: 'http://dummyimage.com/{width}x{height}/efefef/f00&text=Image+not+found'
MD5 thumbnail saving
{md5}
param in thumbPathMask
takes file path and file name, converts it to md5 hash and then saves it in nested directories to avoid having millions of files in one folder. For example let's say md5 hash of my src location somedir/project/www/images/users/1/profile.jpg
is e728fdeab7e2edda33f36fbf7a2b7c82 so using this thumbPathMask
:
thumbPathMask: 'images/thumbs/{md5}/{width}x{height}-{crop}.{extension}'
it gets stored in images/thumbs/e/7/2/e728fdeab7e2edda33f36fbf7a2b7c82/{width}x{height}-{crop}.jpg