ManageAssets: add thumbnails to asset table

This commit is contained in:
2024-08-27 12:00:46 +02:00
parent 01954d4a7d
commit 814a1f82f6
3 changed files with 32 additions and 10 deletions

View File

@@ -45,6 +45,34 @@ class ManageAssets extends HTMLController
},
],
],
'thumbnail' => [
'header' => ' ',
'is_sortable' => false,
'cell_class' => 'text-center',
'parse' => [
'type' => 'function',
'data' => function($row) {
$asset = Image::byRow($row);
$width = $height = 65;
if ($asset->isImage())
{
if ($asset->isPortrait())
$width = null;
else
$height = null;
$thumb = $asset->getThumbnailUrl($width, $height);
}
else
$thumb = BASEURL . '/images/nothumb.svg';
$width = isset($width) ? $width . 'px' : 'auto';
$height = isset($height) ? $height . 'px' : 'auto';
return sprintf('<img src="%s" style="width: %s; height: %s;">', $thumb, $width, $height);
},
],
],
'id_asset' => [
'value' => 'id_asset',
'header' => 'ID',
@@ -107,7 +135,7 @@ class ManageAssets extends HTMLController
$data = Registry::get('db')->queryAssocs('
SELECT a.id_asset, a.subdir, a.filename,
a.image_width, a.image_height,
a.image_width, a.image_height, a.mimetype,
u.id_user, u.first_name, u.surname
FROM assets AS a
LEFT JOIN users AS u ON a.id_user_uploaded = u.id_user