The plugin comes with an Image helper that makes it easy to display the images generated by the ImageStorage model and the events that process the images.
namespace App\View;
class AppView extends View {
public function initialize() {
parent::initialize();
$this->loadHelper('Burzum/FileStorage.Image');
}
}
In your views you can now access all your image versions, which you have declared before in your config through the helper.
echo $this->Image->display($product['image'], 'small');
If you want the original image just call the display() method without a version.
echo $this->Image->display($product['image']);
If you want to get only the URL to an image you can call imageUrl()
.
$imageUrl = $this->Image->imageUrl($product['image'], 'small');
echo $this->Html->image($imageUrl);
The third argument of both methods is an option array, right now it has only one option to set.
- fallback: Optional, can be boolean true or string. If boolean true it will use
placeholder/<YOUR-VERSION>.jpg
as place holder. If string it will use that as image.