/** * Remove files of images from dir * * @param $group * @param $id */ public static function remove_fimage($group, $id) { if (self::$_cache_config === NULL) { self::$_cache_config = Kohana::$config->get($group); } if (self::$_cache_fs === NULL) { self::$_cache_fs = new Symfony\Component\Filesystem\Filesystem(); } $img_many = ORM::factory(self::$_cache_config['model_many'])->where(self::$_cache_config['foreign_key'], '=', $id)->find_all(); foreach ($img_many as $img_item) { $full_name = UPLOAD_DIR . self::$_cache_config['dir'] . DS . $img_item->{self::$_cache_config['fn']}; if (is_file($full_name)) { // Remove image from dir self::$_cache_fs->remove($full_name); // If image has thumbnails if (self::$_cache_config['thumbnails']) { foreach (self::$_cache_config['thumbnails'] as $thumbnail) { // Remove thumbnails images from dir self::$_cache_fs->remove(UPLOAD_DIR . self::$_cache_config['dir'] . DS . $thumbnail['dir'] . DS . $img_item->{self::$_cache_config['fn']}); } } } } }