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
976 B

  1. <?php
  2. class Image extends File
  3. {
  4. public $width;
  5. public $height;
  6. public $type;
  7. public $size;
  8. public $original_filename;
  9. public $variants = array();
  10. const SIZE_100_80 = '100x80';
  11. const SIZE_200_160 = '200x160';
  12. const SIZE_300_240 = '300x240';
  13. const SIZE_550_440 = '550x440';
  14. const SIZE_SKI = 'x';
  15. const SIZE_INSTRUCTION = 'x';
  16. public static $sizes = array(
  17. self::SIZE_100_80,
  18. self::SIZE_200_160,
  19. self::SIZE_300_240,
  20. self::SIZE_550_440
  21. );
  22. /**
  23. * @param $size string
  24. * @return Image
  25. */
  26. public function getVariant($size)
  27. {
  28. if (!array_key_exists($size, $this->variants)) {
  29. $this->variants[$size] = new ImageVariant;
  30. } else {
  31. if (!is_object($this->variants[$size])) {
  32. $this->variants[$size] = parent::getInstance($this->variants[$size]);
  33. }
  34. }
  35. return $this->variants[$size];
  36. }
  37. }