Files
image/Image.class.php

42 lines
976 B
PHP
Raw Normal View History

2013-05-24 13:27:47 +04:00
<?php
class Image extends File
2013-05-24 13:27:47 +04:00
{
public $width;
public $height;
public $type;
public $size;
2013-05-24 13:27:47 +04:00
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 = 'x';
const SIZE_INSTRUCTION = 'x';
2013-05-24 13:27:47 +04:00
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;
2013-05-24 13:27:47 +04:00
} else {
if (!is_object($this->variants[$size])) {
$this->variants[$size] = parent::getInstance($this->variants[$size]);
2013-05-24 13:27:47 +04:00
}
}
return $this->variants[$size];
}
}