PHP code example of tomaj / nette-images

1. Go to this page and download the library: Download tomaj/nette-images library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomaj / nette-images example snippets


$context = $this->context;
$this->template->registerHelper('thumb', function($identifier, $type, $size = '') use ($context) {
	$imageService = $context->getService($type . 'Image');
	return \Tomaj\Image\Helper\Image::thumb($imageService, $identifier, $size);
});

$itemImage = $this->context->getService('itemImage')
$thumbUrl = $itemImage->url($identifier, '320x200');
// alebo pre povodny obrazok
$orginalUrl = $itemImage->url($identifier);

$promoImageService = $container->getService('promoImage');
foreach ($container->getService('promoRepository')->findAll() as $promo) {
	$promoImageService->regenerateThumb($promo->image, '20x20');
}