diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-09-07 22:23:54 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-09-07 22:23:54 -0700 |
commit | 4ba93b7cfc2889dc7cef6729681dd779451f90bf (patch) | |
tree | 691520118d1707b716d090e70a1956f4047210b0 /modules/gallery/models | |
parent | afeb3bb8c47b4ffbacf4585946005bb899ef516b (diff) |
Return the size in bytes of the thumb, resize and full file.
Don't return thumb info if there's no thumbnail (eg: album w/ no contents)
Don't return file_url_public for albums
Fixes ticket #1347.
Diffstat (limited to 'modules/gallery/models')
-rw-r--r-- | modules/gallery/models/item.php | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 485cd8cf..cdba0241 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -977,23 +977,30 @@ class Item_Model extends ORM_MPTT { $data["web_url"] = $this->abs_url(); - if (access::can("view_full", $this) && !$this->is_album()) { - $data["file_url"] = rest::url("data", $this, "full"); - } - if (access::user_can(identity::guest(), "view_full", $this)) { - $data["file_url_public"] = $this->file_url(true); + if (!$this->is_album()) { + if (access::can("view_full", $this)) { + $data["file_url"] = rest::url("data", $this, "full"); + $data["file_size"] = filesize($this->file_path()); + } + if (access::user_can(identity::guest(), "view_full", $this)) { + $data["file_url_public"] = $this->file_url(true); + } } if ($this->is_photo()) { $data["resize_url"] = rest::url("data", $this, "resize"); + $data["resize_size"] = filesize($this->resize_path()); if (access::user_can(identity::guest(), "view", $this)) { $data["resize_url_public"] = $this->resize_url(true); } } - $data["thumb_url"] = rest::url("data", $this, "thumb"); - if (access::user_can(identity::guest(), "view", $this)) { - $data["thumb_url_public"] = $this->thumb_url(true); + if ($this->has_thumb()) { + $data["thumb_url"] = rest::url("data", $this, "thumb"); + $data["thumb_size"] = filesize($this->thumb_path()); + if (access::user_can(identity::guest(), "view", $this)) { + $data["thumb_url_public"] = $this->thumb_url(true); + } } $data["can_edit"] = access::can("edit", $this); |