summaryrefslogtreecommitdiff
path: root/core/models
diff options
context:
space:
mode:
Diffstat (limited to 'core/models')
-rw-r--r--core/models/item.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/core/models/item.php b/core/models/item.php
index 34b8a8dd..0d5e6e11 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -98,9 +98,7 @@ class Item_Model extends ORM_MPTT {
$parent = $this->parent();
if ($parent->album_cover_item_id == $this->id) {
- // @todo change the album cover to some other random image inside the album
- $parent->album_cover_item_id = null;
- $parent->save();
+ $parent->remove_album_cover();
}
$original_path = $this->file_path();
@@ -158,6 +156,26 @@ class Item_Model extends ORM_MPTT {
return $this;
}
+ function make_album_cover() {
+ $parent = $this->parent();
+ access::required("edit", $parent);
+
+ $parent->album_cover_item_id = $this->is_photo() ? $this->id : $this->album_cover_item_id;
+ $parent->thumb_dirty = 1;
+ $parent->save();
+ graphics::generate($parent);
+ }
+
+ function remove_album_cover() {
+ @unlink($this->thumb_path());
+
+ // @todo change the album cover to some other random image inside the album
+ $this->album_cover_item_id = null;
+ $this->thumb_dirty = 1;
+ $this->save();
+ graphics::generate($this);
+ }
+
/**
* album: url::site("albums/2")
* photo: url::site("photos/3")