diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-08-27 17:04:48 -0700 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-27 17:04:48 -0700 |
| commit | a28dd09c4eac11ce406525ffd871df7605d5175f (patch) | |
| tree | 6b3cdfb65c0e690c26b8fc1f360f3ed6316fe08c /modules/gallery/helpers | |
| parent | 5235c7a0b79d12305d99fdafe2710583f5368fcc (diff) | |
Properly deal with invalid images. This fixes ticket #611 which shows
a BMP masquerading as a .jpg causing us to be unable to rebuild
resizes and thumbnails. Now if that happens, we discard the file, log
it and move on.
Diffstat (limited to 'modules/gallery/helpers')
| -rw-r--r-- | modules/gallery/helpers/photo.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index 5cf37de1..96a66d29 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -109,8 +109,12 @@ class photo_Core { // there's only one save() happening here. module::event("item_created", $photo); - // Build our thumbnail/resizes - graphics::generate($photo); + // Build our thumbnail/resizes. If we fail to build thumbnail/resize we assume that the image + // is bad in some way and discard it. + if (!graphics::generate($photo)) { + $photo->delete(); + throw new Exception("@todo BAD_IMAGE_FILE"); + } // If the parent has no cover item, make this it. if (access::can("edit", $parent) && $parent->album_cover_item_id == null) { |
