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.

45 lines
998 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. protected static $sizes = array();
  11. /**
  12. * @param $class string
  13. * @throws ErrorException
  14. */
  15. public static function checkSubClass($class)
  16. {
  17. if (is_null($class) || $class == '') {
  18. throw new ErrorException('Class not defined.');
  19. }
  20. if (!class_exists($class)) {
  21. throw new ErrorException('Class "' . $class . '" not exists.');
  22. }
  23. if (get_parent_class($class) != 'Image') {
  24. throw new ErrorException('Class "' . $class . '" mast be extend of "Image".');
  25. }
  26. }
  27. public function getSizes()
  28. {
  29. return static::$sizes;
  30. }
  31. public function getVariant($size)
  32. {
  33. return parent::getImageVariant($size);
  34. }
  35. public function getIsNoEmpty()
  36. {
  37. return (bool) $this->size;
  38. }
  39. }