aboutsummaryrefslogtreecommitdiff
path: root/lib/image.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/image.php')
-rw-r--r--lib/image.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/image.php b/lib/image.php
index a22e1db1c..7c7ef2d90 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -29,6 +29,12 @@ class TidypicsImage extends ElggFile {
$album->removeImage($this->guid);
}
+ $this->removeThumbnails();
+
+ // update quota
+ $owner = $this->getOwnerEntity();
+ $owner->image_repo_size = (int)$owner->image_repo_size - $this->size();
+
return parent::delete();
}
@@ -146,6 +152,40 @@ class TidypicsImage extends ElggFile {
create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC);
}
}
+
+ /**
+ * Remove thumbnails - usually in preparation for deletion
+ *
+ * The thumbnails are not actually ElggObjects so we create
+ * temporary objects to delete them.
+ */
+ protected function removeThumbnails() {
+ $thumbnail = $this->thumbnail;
+ $smallthumb = $this->smallthumb;
+ $largethumb = $this->largethumb;
+
+ //delete standard thumbnail image
+ if ($thumbnail) {
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $this->getOwner();
+ $delfile->setFilename($thumbnail);
+ $delfile->delete();
+ }
+ //delete small thumbnail image
+ if ($smallthumb) {
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $this->getOwner();
+ $delfile->setFilename($smallthumb);
+ $delfile->delete();
+ }
+ //delete large thumbnail image
+ if ($largethumb) {
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $this->getOwner();
+ $delfile->setFilename($largethumb);
+ $delfile->delete();
+ }
+ }
}
/**