PHP code example of xavier83ar / image-presenter

1. Go to this page and download the library: Download xavier83ar/image-presenter 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/ */

    

xavier83ar / image-presenter example snippets


Plugin::load('ImagePresenter', ['routes' => true]);

'ImagePresenter' => [
    'variants' => [
        'thumbnail' => [
            'size' => [350, 250],
            'mode' => ImageInterface::THUMBNAIL_OUTBOUND,
            'filter' => ImageInterface::FILTER_LANCZOS
        ],
        'mini' => [
            'operation' => 'thumbnail',
            'size' => [120, 120],
            'mode' => ImageInterface::THUMBNAIL_INSET,
        ],
        'other' => [
            'operation' => function (ImageInterface $imagine) {
                return $imagine->resize(new Box(400, 300))->rotate(90);
            }
        ],
        'amazing' => [
            'operation' => function (ImageInterface $imagine) {
                return $imagine
                    ->resize(new Box(600, 320))
                    ->effects()->grayscale()->blur(5);
            }
        ],
    ],
]

class AppView extends View
{
    public function initialize()
    {
        $this->loadHelper('ImagePresenter.Image');
    }
}

<img src="<?= $this->Image->variant($img, 'thumbnail')