}
if (!file_exists($imgPath)) {
- throw new ServerException(sprintf('Image not available locally: %s', $imgPath));
+ throw new FileNotFoundException($imgPath);
}
try {
$image = new ImageFile($file->getID(), $imgPath);
} catch (Exception $e) {
- common_debug(sprintf('Exception caught when creating ImageFile for File id==%s and imgPath==', _ve($file->id), _ve($imgPath)));
- throw $e;
- } finally {
// Avoid deleting the original
try {
if (strlen($imgPath) > 0 && $imgPath !== $file->getPath()) {
// doesn't exist anyway, so it's safe to delete $imgPath
@unlink($imgPath);
}
+ common_debug(sprintf('Exception caught when creating ImageFile for File id==%s and imgPath==', _ve($file->id), _ve($imgPath)));
+ throw $e;
}
return $image;
}
list($width, $height, $x, $y, $w, $h) = $this->scaleToFit($width, $height, $crop);
$thumb = File_thumbnail::pkeyGet(array(
- 'file_id'=> $this->fileRecord->id,
+ 'file_id'=> $this->fileRecord->getID(),
'width' => $width,
'height' => $height,
));
$filename = $this->fileRecord->filehash ?: $this->filename; // Remote files don't have $this->filehash
$extension = File::guessMimeExtension($this->mimetype);
- $outname = "thumb-{$this->fileRecord->id}-{$width}x{$height}-{$filename}." . $extension;
+ $outname = "thumb-{$this->fileRecord->getID()}-{$width}x{$height}-{$filename}." . $extension;
$outpath = File_thumbnail::path($outname);
// The boundary box for our resizing
throw new ServerException('Bad thumbnail size parameters.');
}
- common_debug(sprintf('Generating a thumbnail of File id==%u of size %ux%u', $this->fileRecord->id, $width, $height));
+ common_debug(sprintf('Generating a thumbnail of File id==%u of size %ux%u', $this->fileRecord->getID(), $width, $height));
// Perform resize and store into file
$this->resizeTo($outpath, $box);