diff options
-rw-r--r-- | core/controllers/quick.php | 16 | ||||
-rw-r--r-- | core/js/quick.js | 22 | ||||
-rw-r--r-- | core/views/quick_pane.html.php | 4 |
3 files changed, 30 insertions, 12 deletions
diff --git a/core/controllers/quick.php b/core/controllers/quick.php index e382a444..44ca32b4 100644 --- a/core/controllers/quick.php +++ b/core/controllers/quick.php @@ -72,6 +72,22 @@ class Quick_Controller extends Controller { "height" => $item->thumb_height)); } + public function make_album_cover($id) { + access::verify_csrf(); + $item = ORM::factory("item", $id); + access::required("edit", $item); + + $parent = $item->parent(); + access::required("edit", $parent); + + $parent->album_cover_item_id = $item->id; + $parent->thumb_dirty = 1; + $parent->save(); + graphics::generate($parent); + + print json_encode(array("result" => "success")); + } + public function form_edit($id) { $item = ORM::factory("item", $id); access::required("edit", $item); diff --git a/core/js/quick.js b/core/js/quick.js index 36b6f250..e662f77f 100644 --- a/core/js/quick.js +++ b/core/js/quick.js @@ -48,16 +48,18 @@ var quick_do = function(cont, pane, img) { url: pane.attr("href"), dataType: "json", success: function(data) { - img.css("opacity", "1"); - img.attr("width", data.width); - img.attr("height", data.height); - img.attr("src", data.src); - if (data.height > data.width) { - img.css("margin-top", -32); - } else { - img.css("margin-top", 0); - } - cont.removeClass("gLoadingLarge"); + img.css("opacity", "1"); + if (data.src) { + img.attr("width", data.width); + img.attr("height", data.height); + img.attr("src", data.src); + if (data.height > data.width) { + img.css("margin-top", -32); + } else { + img.css("margin-top", 0); + } + } + cont.removeClass("gLoadingLarge"); } }); } diff --git a/core/views/quick_pane.html.php b/core/views/quick_pane.html.php index dfae4d15..d3977a39 100644 --- a/core/views/quick_pane.html.php +++ b/core/views/quick_pane.html.php @@ -28,8 +28,8 @@ </span> </a> -<? if ($item->type == "photo"): ?> -<a class="cover" href="#" +<? if ($item->type == "photo" && access::can("edit", $item->parent())): ?> +<a class="cover" href="<?= url::site("quick/make_album_cover/$item->id?csrf=" . access::csrf_token()) ?>" title="<?= t("Select as album cover") ?>"> <span> <?= t("Select as album cover") ?> |