forked from Public/pics
EditAlbum: allow specifying a thumbnail ID manually if none are present
This commit is contained in:
parent
5cff62836e
commit
5b8551a726
@ -72,15 +72,17 @@ class EditAlbum extends HTMLController
|
||||
$parentChoices[$parent['id_tag']] = $parent['tag'];
|
||||
}
|
||||
|
||||
$form = new Form([
|
||||
'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
|
||||
'content_below' => $after_form,
|
||||
'fields' => [
|
||||
$fields = [
|
||||
'id_parent' => [
|
||||
'type' => 'select',
|
||||
'label' => 'Parent album',
|
||||
'options' => $parentChoices,
|
||||
],
|
||||
'id_asset_thumb' => [
|
||||
'type' => 'numeric',
|
||||
'label' => 'Thumbnail asset ID',
|
||||
'is_optional' => true,
|
||||
],
|
||||
'tag' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Album title',
|
||||
@ -100,9 +102,28 @@ class EditAlbum extends HTMLController
|
||||
'maxlength' => 255,
|
||||
'is_optional' => true,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Fetch image assets for this album
|
||||
if (!empty($id_tag))
|
||||
{
|
||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||
'direction' => 'desc',
|
||||
'limit' => 500,
|
||||
'id_tag' => $id_tag,
|
||||
], true);
|
||||
|
||||
if ($num_assets > 0)
|
||||
unset($fields['id_asset_thumb']);
|
||||
}
|
||||
|
||||
$form = new Form([
|
||||
'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
|
||||
'content_below' => $after_form,
|
||||
'fields' => $fields,
|
||||
]);
|
||||
|
||||
// Add defaults for album if none present
|
||||
if (empty($_POST) && isset($_GET['tag']))
|
||||
{
|
||||
$parentTag = Tag::fromId($_GET['tag']);
|
||||
@ -124,17 +145,9 @@ class EditAlbum extends HTMLController
|
||||
$formview = new FormView($form, $form_title ?? '');
|
||||
$this->page->adopt($formview);
|
||||
|
||||
if (!empty($id_tag))
|
||||
{
|
||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||
'direction' => 'desc',
|
||||
'limit' => 500,
|
||||
'id_tag' => $id_tag,
|
||||
], true);
|
||||
|
||||
if ($num_assets > 0)
|
||||
// If we have asset images, show the thumbnail manager
|
||||
if (!empty($id_tag) && $num_assets > 0)
|
||||
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0));
|
||||
}
|
||||
|
||||
if (isset($_POST['changeThumbnail']))
|
||||
$this->processThumbnail($album);
|
||||
|
Loading…
Reference in New Issue
Block a user