summaryrefslogtreecommitdiff
path: root/modules/gallery/models/item.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-08-14 16:10:32 -0700
committerBharat Mediratta <bharat@menalto.com>2010-08-14 16:10:32 -0700
commitdbe595f15e9c3f359fa447cf270e914b6d6d809e (patch)
tree7b295998fb68edaf2fa3e19652a376ec2d9f7ba9 /modules/gallery/models/item.php
parentb562751fdb2ae8aab3a344e84176ea03381ca04c (diff)
Always use the data resource to return thumbs, resizes and full sizes.
That way the client does not have to differentiate between RESTful request types and raw request types. If there's a public raw url, return that as well.
Diffstat (limited to 'modules/gallery/models/item.php')
-rw-r--r--modules/gallery/models/item.php30
1 files changed, 14 insertions, 16 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 1dea60e8..c4591279 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -668,9 +668,9 @@ class Item_Model extends ORM_MPTT {
public function resize_img($extra_attrs) {
$attrs = array_merge($extra_attrs,
array("src" => $this->resize_url(),
- "alt" => $this->title,
- "width" => $this->resize_width,
- "height" => $this->resize_height)
+ "alt" => $this->title,
+ "width" => $this->resize_width,
+ "height" => $this->resize_height)
);
// html::image forces an absolute url which we don't want
return "<img" . html::attributes($attrs) . "/>";
@@ -973,27 +973,25 @@ class Item_Model extends ORM_MPTT {
}
unset($data["album_cover_item_id"]);
- if (access::can("view_full", $this) && $this->is_photo()) {
- if (access::user_can(identity::guest(), "view_full", $this)) {
- $data["file_url"] = $this->file_url(true);
- } else {
- $data["file_url"] = rest::url("data", $this, "full");
- }
+ 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 (($tmp = $this->resize_url(true)) && $this->is_photo()) {
+ if ($this->is_photo()) {
+ $data["resize_url"] = rest::url("data", $this, "resize");
if (access::user_can(identity::guest(), "view", $this)) {
- $data["resize_url"] = $tmp;
- } else {
- $data["resize_url"] = rest::url("data", $this, "resize");
+ $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"] = $this->thumb_url(true);
- } else {
- $data["thumb_url"] = rest::url("data", $this, "thumb");
+ $data["thumb_url_public"] = $this->thumb_url(true);
}
+
$data["can_edit"] = access::can("edit", $this);
// Elide some internal-only data that is going to cause confusion in the client.