return File_thumbnail::byFile($this);
} catch (NoResultException $e) {
// and if it's not a remote file, it'll be safe to use the locally stored File
- throw new UseFileAsThumbnailException($this->id);
+ throw new UseFileAsThumbnailException($this);
}
}
}
// First some mimetype specific exceptions
switch ($file->mimetype) {
case 'image/svg+xml':
- throw new UseFileAsThumbnailException($file->id);
+ throw new UseFileAsThumbnailException($file);
}
// And we'll only consider it an image if it has such a media type
}
if (!file_exists($outpath)) {
- throw new UseFileAsThumbnailException($this->id);
+ if ($this->fileRecord instanceof File) {
+ throw new UseFileAsThumbnailException($this->fileRecord);
+ } else {
+ throw new UnsupportedMediaException('No local File object exists for ImageFile.');
+ }
}
return $outpath;
{
public $file = null;
- public function __construct($file_id)
+ public function __construct(File $file)
{
- $this->file = File::getKV('id', $file_id);
- if (!$this->file instanceof File) {
- throw new ServerException('No File ID supplied to exception');
- }
-
+ $this->file = $file;
parent::__construct('Thumbnail not generated', $this->file->getPath());
}
}