ImageHelper::thumb PHP Méthode

thumb() public static méthode

* Create a thumbnail of an image and returns relative path in webroot * the options array is an associative array which can take the values * quality (jpg quality) and method (the method for resizing) * * @param int $width * @param int $height * @param string $img * @param array $options * @return string $path
public static thumb ( integer $width, integer $height, string $img, array $options = null ) : string
$width integer
$height integer
$img string
$options array
Résultat string
class ImageHelper
{
    /**
     * Directory to store thumbnails
     * @var string 
     */
    const THUMB_DIR = '.tmb';
    /**
     * Create a thumbnail of an image and returns relative path in webroot
     * the options array is an associative array which can take the values
     * quality (jpg quality) and method (the method for resizing)
     *
     * @param int $width
     * @param int $height
     * @param string $img
     * @param array $options
     * @return string $path
     */
    public static function thumb($width, $height, $img, $options = null)
    {
        if (!file_exists($img)) {
            $img = str_replace('\\', '/', YiiBase::getPathOfAlias('webroot') . $img);
            if (!file_exists($img)) {
                throw new ExceptionClass('Image not found');
            }
        }
        // Jpeg quality
        $quality = 80;
        // Method for resizing
        $method = 'adaptiveResize';
        if ($options) {
            extract($options, EXTR_IF_EXISTS);
        }

Usage Example

Exemple #1
0
 public static function getChildsId($id)
 {
     $data = array();
     $ids = array();
     if (!is_array($id)) {
         $id = array($id);
     }
All Usage Examples Of ImageHelper::thumb
ImageHelper