From 4ba93b7cfc2889dc7cef6729681dd779451f90bf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 7 Sep 2010 22:23:54 -0700 Subject: [PATCH] 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. --- modules/gallery/models/item.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 485cd8cf9e..cdba0241f7 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -977,23 +977,30 @@ public function as_restful_array() { $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);