Skip to content

Commit

Permalink
Return the size in bytes of the thumb, resize and full file.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bharat committed Sep 8, 2010
1 parent afeb3bb commit 4ba93b7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions modules/gallery/models/item.php
Expand Up @@ -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);
Expand Down

0 comments on commit 4ba93b7

Please sign in to comment.