diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2013-01-30 17:17:06 -0800 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2013-01-30 17:17:06 -0800 |
| commit | d8d01e0aa0cac2b8576ae481527d875213cdc3a7 (patch) | |
| tree | 1d56ab326ae495eaefaf2ecd8d411a27552ff83f /modules/gallery/models | |
| parent | 0ab40de11d65476454d4bf1129916a6856001002 (diff) | |
| parent | cf077425953a6a492dea97eaf1517e7d08c9648f (diff) | |
Merge pull request #112 from shadlaws/fix_1968
#1968 - Improve album cover generation/removal/etc.
Diffstat (limited to 'modules/gallery/models')
| -rw-r--r-- | modules/gallery/models/item.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 60318c26..f9edd3c6 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -420,6 +420,15 @@ class Item_Model_Core extends ORM_MPTT { } } + // If an album's cover has changed (or been removed), delete any existing album cover, + // reset the thumb metadata, and mark the thumb as dirty. + if (array_key_exists("album_cover_item_id", $this->changed) && $this->is_album()) { + @unlink($original->thumb_path()); + $this->thumb_dirty = 1; + $this->thumb_height = 0; + $this->thumb_width = 0; + } + if (array_intersect($this->changed, array("parent_id", "name", "slug"))) { $original->_build_relative_caches(); $this->relative_path_cache = null; @@ -966,10 +975,12 @@ class Item_Model_Core extends ORM_MPTT { return; } - if ($this->album_cover_item_id && db::build() + if ($this->album_cover_item_id && ($this->is_photo() || $this->is_movie() || + db::build() ->from("items") ->where("id", "=", $this->album_cover_item_id) - ->count_records() != 1) { + ->where("type", "<>", "album") + ->count_records() != 1)) { $v->add_error("album_cover_item_id", "invalid_item"); } } |
