2017 © Pedro Peláez
 

library thumbnail

PHP class for thumbnails creation

image

makeitbetter/thumbnail

PHP class for thumbnails creation

  • Sunday, October 22, 2017
  • by makeitbetter
  • Repository
  • 0 Watchers
  • 0 Stars
  • 17 Installations
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

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']);?>

The Versions

22/10 2017

dev-master

9999999-dev http://makeitbetter.su/projects/thumbnail

PHP class for thumbnails creation

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6

 

php thumbnail makeitbetter

22/10 2017

v1.0.1

1.0.1.0 http://makeitbetter.su/projects/thumbnail

PHP class for thumbnails creation

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6

 

php thumbnail makeitbetter

14/07 2017

v1.0

1.0.0.0 http://makeitbetter.su/projects/thumbnail

PHP class for thumbnails creation

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6

 

php thumbnail makeitbetter