diff --git a/File.class.php b/File.class.php index db2574f..d284ff4 100644 --- a/File.class.php +++ b/File.class.php @@ -110,6 +110,30 @@ abstract class File return (bool) $this->size; } + public function delete() + { + /** + * @var $image Image + */ + if ($this->getIsNoEmpty()) { + unlink($this->getRealPath()); + } + if (get_parent_class($this) == 'Image') { + $image = $this; + foreach ($image->variants as $size) { + $image_variant = $image->getVariant($size); + if ($image_variant->getIsNoEmpty()) { + unlink($image->getRealPath()); + } + } + } + } + + public function getRealPath() + { + return PATH_WEB_ROOT . '/' . $this->path . '/' . $this->filename; + } + /** * @return string */