Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Latest commit

 

History

History
40 lines (29 loc) · 1.2 KB

The-Image-Helper.md

File metadata and controls

40 lines (29 loc) · 1.2 KB

The Image Helper

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);

Options for display() and 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.