File width and height is now properly set for File

This commit is contained in:
Mikael Nordfeldth
2014-04-22 12:09:24 +02:00
parent 5fbb668855
commit e526909bd8
4 changed files with 98 additions and 62 deletions

View File

@@ -428,16 +428,23 @@ function fixupFileGeometry()
if ($file->find()) {
while ($file->fetch()) {
// Add support for video sizes too
// Set file geometrical properties if available
try {
$image = new ImageFile($file->id, $file->getPath());
} catch (UnsupportedMediaException $e) {
$image = ImageFile::fromFileObject($file);
} catch (ServerException $e) {
// We couldn't make out an image from the file.
continue;
}
$orig = clone($file);
$file->width = $image->width;
$file->height = $image->height;
$file->update($orig);
// FIXME: Do this more automagically inside ImageFile or so.
if ($image->getPath() != $file->getPath()) {
$image->unlink();
}
unset($image);
}
}