diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-06-25 10:27:44 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-06-25 10:27:44 -0700 |
commit | 8aa2f1fb84c4e94fe1ffa172992d43c1125f1090 (patch) | |
tree | 1eeace0af37391483217c563d8d4e6335bc93ac7 /modules | |
parent | 71b5412627662ee04d34844b0f90ded712ad2ec7 (diff) | |
parent | 142088a6353dfd051e0dc72e1e30fa51fb6d7f2b (diff) |
Merge pull request #53 from chadparry/missing_photo
Gracefully handle rule failures with a broken image icon. Fixes #1755.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/helpers/graphics.php | 22 | ||||
-rw-r--r-- | modules/gallery/images/missing_photo.png | bin | 0 -> 1570 bytes |
2 files changed, 18 insertions, 4 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index acb11bfb..39c87fbd 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -170,23 +170,37 @@ class graphics_Core { foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args), $item); - call_user_func_array($rule->operation, $args); - $working_file = $output_file; + try { + call_user_func_array($rule->operation, $args); + $working_file = $output_file; + } catch (Exception $e) { + // Ignore this rule and move on. + Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } } } if (!empty($ops["thumb"])) { + if (file_exists($item->thumb_path())) { + $item->thumb_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path()); + } $dims = getimagesize($item->thumb_path()); $item->thumb_width = $dims[0]; $item->thumb_height = $dims[1]; - $item->thumb_dirty = 0; } if (!empty($ops["resize"])) { + if (file_exists($item->resize_path())) { + $item->resize_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path()); + } $dims = getimagesize($item->resize_path()); $item->resize_width = $dims[0]; $item->resize_height = $dims[1]; - $item->resize_dirty = 0; } $item->save(); } catch (Exception $e) { diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png Binary files differnew file mode 100644 index 00000000..67786275 --- /dev/null +++ b/modules/gallery/images/missing_photo.png |