Blame view

backend/components/noam148/imageresize/README.md 1.39 KB
a8aa0f7d   alex   Add new noam148 m...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  Image resize for Yii2
  ========================
  
  A Yii2 component for resizing images and store it in a cache folder
  
  Installation
  ------------
  The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
  
  * Either run
  
  ```
  php composer.phar require "noam148/yii2-image-resize" "*"
  ```
  or add
  
  ```json
  "noam148/yii2-image-resize" : "*"
  ```
  
  to the require section of your application's `composer.json` file.
  
  * Add a new component in `components` section of your application's configuration file, for example:
  
  ```php
  'components' => [
      'imageresize' => [
  		'class' => 'noam148\imageresize\ImageResize',
  		//path relative web folder
  		'cachePath' => '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,
  	],
  ],
  ```
  
  Usage
  -----
  
  If you want to get a image url:
  
  ```php
  /*
   * $sImageFilePath_id: (required) path to file
   * $width/$height: (required) width height of the image
   * $mode: "outbound" or "inset" 
   * $$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);
  ```
  
  **If you got questions, tips or feedback? Please, let me know!**