PHP code example of mrumengan / yii2-image-resize

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

    

mrumengan / yii2-image-resize example snippets


'components' => [
    'imageresize' => [
		'class' => 'mrumengan\imageresize\ImageResize',
		//path relative web folder. In case of multiple environments (frontend, backend) add more paths
		'cachePath' =>  ['assets/images', '../../frontend/web/assets/images'],
		//use filename (seo friendly) for resized images else use a hash
		'useFilename' => true,
		//show full url (for example in case of a API)
		'absoluteUrl' => false,
	],
],

/*
 * $sImageFilePath_id: () width height of the image
 * $mode: "outbound", "inset" or "{horz}:{vert}" where {horz} is one from "left", "cetrer", "right" and {vert} is one from "top", "center", "bottom"
 * $$quality: (1 - 100)
 * $chosenFileName: if config -> components -> imageresize -> useFilename is true? its an option to give a custom name else use original file name
 */
\Yii::$app->imageresize->getUrl($sImageFilePath, $width, $height, $mode, $quality, $chosenFileName);

php composer.phar