tomaskarlik / storages
File and image storage.
1.0beta
2017-07-16 23:46 UTC
Requires
- php: >=5.6
- latte/latte: ^2.4.0
- nette/http: ~2.4.0
- nette/utils: ^2.4.0
This package is not auto-updated.
Last update: 2024-09-01 02:46:50 UTC
README
Keep original file without changes.
Requirements
ImageStorage / FileStorage requires PHP 5.6 or higher.
Usage
Presenter
class MyPresenter extends BasePresenter { use TStoragePresenter; //or inject dependency to template manualy }
config.neon
parameters:
images:
original: 'pictures/original' #relative from %wwwDir%
thumbs: 'pictures/tn'
sizes: ['100x100'] #pre-cached sizes
uploads: 'uploads'
services:
- TomasKarlik\Storages\FileStorage(%wwwDir%, %uploads%)
- TomasKarlik\Storages\ImageStorage(%wwwDir%, %images.original%, %images.thumbs%, %images.sizes%)
nette:
latte:
macros:
- TomasKarlik\Storages\Macros\FileMacros::install
- TomasKarlik\Storages\Macros\ImageMacros::install
Template
<img n:img="'namespace', $item->picture, NULL, 320, 240, \Nette\Utils\Image::EXACT" alt="{$item->name}"> <img n:img="'namespace', 'picture', 'jpg'"> <!-- define extension of original file sepratly -->
Save image
$this->image->setNamespace('myNamespace'); $this->image->save($upload, $filename);