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.

40 lines
946 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 = '1000x';
  15. public static $sizes = array(
  16. self::SIZE_100_80,
  17. self::SIZE_200_160,
  18. self::SIZE_300_240,
  19. self::SIZE_550_440
  20. );
  21. /**
  22. * @param $size string
  23. * @return Image
  24. */
  25. public function getVariant($size)
  26. {
  27. if (!array_key_exists($size, $this->variants)) {
  28. $this->variants[$size] = new ImageVariant;
  29. } else {
  30. if (!is_object($this->variants[$size])) {
  31. $this->variants[$size] = parent::getInstance($this->variants[$size]);
  32. }
  33. }
  34. return $this->variants[$size];
  35. }
  36. }