Thumbnail - PHP class for thumbnails creation., (*1)
Demo: makeitbetter.su/projects/thumbnail, (*2)
Public Variables
public static $sourceFolder
Path to folder with images source., (*3)
public static $targetFolder
Path to folder for thumbnails relative to the webroot., (*4)
public static $webRoot
Path to web root. Default - $_SERVER['DOCUMENT_ROOT'], (*5)
public static $paddingColor
Hexadecimal RGB color to fill thumbnails padding. Default - ffffff., (*6)
public static $getThumbnailPathMethod
Function that will create thumbnails path. Default - $this->_getThumbnailPath(), (*7)
public $path
Path to the image relative to the source folder., (*8)
public $stretch
Whether to stretch the image whose size is less than the size of the thumbnail. Default - false, (*9)
public $crop
Whether to crop the image whose proportions do not match the proportions of the thumbnail. Default - false, (*10)
public $width
Thumbnails width. Default - 0 (Calculate using a source proportions), (*11)
public $height
Thumbnails height. Default - 0 (Calculate using a source proportions), (*12)
Public methods
public static of($path, $width = 0, $height = 0, $crop = false, $stretch = false)
Returns new object., (*13)
public width($width)
Sets the thumbnails width. Height will be calculated using a source proportions. Returns its self., (*14)
public height($height)
Sets the thumbnails height. Width will be calculated using a source proportions. Returns its self., (*15)
public size($width, $height)
Sets the exact size of thumbnails. Returns its self., (*16)
public crop()
Crops the image if its proportions do not match the proportions of the thumbnail. Returns its self., (*17)
public contain()
Scales the image such it can fit inside thumbnails frame (with adding padding). Returns its self., (*18)
public stretch()
Stretches small image to thumbnails size. Returns its self., (*19)
public nostretch()
Leaves the size of small images as is (with adding padding). Returns its self., (*20)
public path()
Creates a thumbnail if it absent. Returns a path to it. This method will be called when trying to convert an object to a string:, (*21)
#!php
<img src="<?php echo Thumbnail::of('images/example.jpg', 100)->path();?>" />
<!-- equals : -->
<img src="<?php echo Thumbnail::of('images/example.jpg', 100);?>" />
public img($attributes = [])
Wraps a path into a HTML-tag img/:, (*22)
#!php
<img src="<?php echo Thumbnail::of('images/example.jpg', 100);?>" class="thumbnail" />
<!-- equals : -->
<?php echo Thumbnail::of('images/example.jpg', 100)->img(['class' => 'thumbnail']);?>