You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
946 B
41 lines
946 B
<?php
|
|
|
|
class Image extends File
|
|
{
|
|
public $width;
|
|
public $height;
|
|
public $type;
|
|
public $size;
|
|
|
|
public $original_filename;
|
|
public $variants = array();
|
|
|
|
const SIZE_100_80 = '100x80';
|
|
const SIZE_200_160 = '200x160';
|
|
const SIZE_300_240 = '300x240';
|
|
const SIZE_550_440 = '550x440';
|
|
const SIZE_SKI = '1000x';
|
|
|
|
public static $sizes = array(
|
|
self::SIZE_100_80,
|
|
self::SIZE_200_160,
|
|
self::SIZE_300_240,
|
|
self::SIZE_550_440
|
|
);
|
|
|
|
/**
|
|
* @param $size string
|
|
* @return Image
|
|
*/
|
|
public function getVariant($size)
|
|
{
|
|
if (!array_key_exists($size, $this->variants)) {
|
|
$this->variants[$size] = new ImageVariant;
|
|
} else {
|
|
if (!is_object($this->variants[$size])) {
|
|
$this->variants[$size] = parent::getInstance($this->variants[$size]);
|
|
}
|
|
}
|
|
return $this->variants[$size];
|
|
}
|
|
}
|