diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-10-23 13:18:57 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-10-23 13:18:57 +0000 |
commit | e0834b7d8b2b79ce230ca56601c7851aba4abe88 (patch) | |
tree | 3dd2e03d7da257000f81d3d0a4fbefa16e736d3e /lib | |
parent | c2f005477cce4312df1bd67a88bb4d644fb14790 (diff) | |
download | elgg-e0834b7d8b2b79ce230ca56601c7851aba4abe88.tar.gz elgg-e0834b7d8b2b79ce230ca56601c7851aba4abe88.tar.bz2 |
better image deletion
Diffstat (limited to 'lib')
-rw-r--r-- | lib/image.php | 40 |
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(); + } + } } /** |