This plugin contains a number of picture associated capabilities. You possibly can modify a picture (resize, crop, scale), get data (dimensions, sort & file dimension), or routinely create a show or an inventory of all pictures in a given listing. Many of the lessons require that GD be enabled in PHP, in any other case there’s not any particular necessities. The examples on this web page are utilizing static pictures, and the returned information simulated as CodeCanyon clearly doesn’t permit operating PHP scripts on this web page. Go to the example page to see the photographs truly being modified on the fly.
It will return fundamental information a few particular picture together with picture sort, width, peak and dimension (in bytes, kilobytes and megabytes).
- Picture sort: png
- Width: 1920
- Peak: 1280
- Dimension in bytes: 1285926
- Dimension in kilobytes: 1285.93
- Dimension in megabytes: 1.29
The perform will scale a picture proprtionally to a particular width. Instance resizes 1920×1280 picture to 300 pixels large.
$image->scale('img/swirly.png', $dest='img/scale.png', $width=300);
The perform will resize a picture to a particular width and peak (is probably not proportional). Instance resizes 1920×1280 picture to 200×300.
$image->resize('img/swirly.png', $dest='img/resize.png', $width=200, $peak300);
This crops a picture to particular dimensions. On this instance the unique 1920×1280 picture is cropped to 690×770 (400px from the left and 300px from the highest).
This remaining perform will create an inventory of all pictures inside a given listing. You possibly can select to show it both as a textual record, or to really show the entire pictures (with an non-compulsory max-width setting).
Textual content Record
The default settings will output a textual content record of all pictures in a listing. By default every picture can be enclosed in anchor tags linking to the file, proceeded by a line break “
”. For those who choose, you may set $line_break to false and also you’ll get a coma separated record as an alternative. For those who simply need to show an inventory with out linking to the file, set $hyperlink to false.
As a substitute of simply itemizing the photographs in a listing, you can too select to show the precise pictures. There’s a max-width setting (set to 160px within the instance) if you wish to maintain the photographs from getting too massive. Every picture additionally has a category of “img_list” if you wish to do any further styling with css. Lastly, there’s additionally a “root” setting in case you want modify the show location. For instance, my CodeIgniter URI rewritting can generally confuse issues (with the browser and php in search of the file at completely different places), so I would like to switch the show path on this web page.
The ultimate choice will return the record as an array as an alternative of displaying the info so that you’re free to format it nevertheless you want.
print_r($image->contents('dirname', $record='array')) /* Information returned by the picture contents array */ Array (  => colourful.jpg  => subject.jpg  => pirate.jpg  => planet.jpg  => tado.jpg  => twister.jpg  => turtle.jpg  => water.jpg )