summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/graphics.php
diff options
context:
space:
mode:
authorshadlaws <shad@shadlaws.com>2013-01-31 17:18:39 +0100
committershadlaws <shad@shadlaws.com>2013-01-31 17:18:39 +0100
commitf83ed5f8716663a45c9d8e8118bbcf0e2849c3fb (patch)
treeb4182b14160868ae1e6043ee1302d3ccf0bcdf68 /modules/gallery/helpers/graphics.php
parente17c39386b9d322f9bafd8b548ec6b94a7c5f7b5 (diff)
#1982 - Add placeholder for albums with no album cover.
- Added missing_album_cover.jpg placeholder image. - Modified the graphics helper to use it. Calling graphics::generate will copy it. - Modified item::remove_album_cover and gallery_event::item_created to run graphics::generate. - Added unit test to Graphics_Helper_Test.
Diffstat (limited to 'modules/gallery/helpers/graphics.php')
-rw-r--r--modules/gallery/helpers/graphics.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 19ae1036..7c8e89d5 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -152,6 +152,7 @@ class graphics_Core {
} catch (Exception $e) {
// Didn't work, likely because of MISSING_FFMPEG - use placeholder
graphics::_replace_image_with_placeholder($item, $target);
+ break;
}
}
$working_file = $output_file;
@@ -167,7 +168,7 @@ class graphics_Core {
case "album":
if (!$cover = $item->album_cover()) {
- // This album has no cover; there's nothing to generate. Because of an old bug, it's
+ // This album has no cover; copy its placeholder image. Because of an old bug, it's
// possible that there's an album cover item id that points to an invalid item. In that
// case, just null out the album cover item id. It's not optimal to do that at this low
// level, but it's not trivial to find these cases quickly in an upgrade script and if we
@@ -179,7 +180,8 @@ class graphics_Core {
$item->album_cover_item_id = null;
$item->save();
}
- return;
+ graphics::_replace_image_with_placeholder($item, $target);
+ break;
}
if ($cover->thumb_dirty) {
graphics::generate($cover);
@@ -238,7 +240,9 @@ class graphics_Core {
}
private static function _replace_image_with_placeholder($item, $target) {
- if ($item->is_movie() || ($item->is_album() && $item->album_cover()->is_movie())) {
+ if ($item->is_album() && !$item->album_cover_item_id) {
+ $input_path = MODPATH . "gallery/images/missing_album_cover.jpg";
+ } else if ($item->is_movie() || ($item->is_album() && $item->album_cover()->is_movie())) {
$input_path = MODPATH . "gallery/images/missing_movie.jpg";
} else {
$input_path = MODPATH . "gallery/images/missing_photo.jpg";