fix(dashboard): фото грузить миниатюрой, а не оригиналом
thumbSrc() в admin.js для /uploads/ отдаёт полный размер, поэтому сетка "Фото групп" и превью "Последних записей" тянули оригиналы (~1.6 MB на фото, 13 MB на блок). Добавлен локальный dashThumb() по образцу photos.js/students.js: /uploads/<name> -> /uploads/thumb/<name> (WebP ~36 KB), прочее — как было. Лайтбокс по-прежнему открывает оригинал через data-img.
This commit is contained in:
@@ -50,13 +50,18 @@ function renderActivity(activity) {
|
||||
</div>`).join('');
|
||||
}
|
||||
|
||||
function dashThumb(p) {
|
||||
if (typeof p === 'string' && p.startsWith('/uploads/')) return `${API}/uploads/thumb/${p.slice('/uploads/'.length)}`;
|
||||
return thumbSrc(p);
|
||||
}
|
||||
|
||||
function renderRecent(rows) {
|
||||
const el = document.getElementById('recentList');
|
||||
if (!rows.length) { el.innerHTML = '<div class="dash-empty">Записей пока нет</div>'; return; }
|
||||
el.innerHTML = rows.map(e => `
|
||||
<div class="recent-item">
|
||||
${e.photo_path
|
||||
? `<img src="${thumbSrc(e.photo_path)}" data-img="${API}${e.photo_path}" loading="lazy" decoding="async" alt="">`
|
||||
? `<img src="${dashThumb(e.photo_path)}" data-img="${API}${e.photo_path}" loading="lazy" decoding="async" alt="">`
|
||||
: `<div class="thumb"><i data-lucide="graduation-cap"></i></div>`}
|
||||
<div class="r-info">
|
||||
<div class="r-name">${esc(e.student_name)}</div>
|
||||
@@ -113,7 +118,7 @@ function renderPhotos(rows) {
|
||||
if (!rows.length) { el.innerHTML = '<div class="dash-empty">Фото групп пока нет</div>'; return; }
|
||||
el.innerHTML = rows.map(p => `
|
||||
<div class="dash-photo" title="${esc(p.group_name)}">
|
||||
<img src="${thumbSrc(p.photo_path)}" data-img="${API}${p.photo_path}" loading="lazy" decoding="async" alt="">
|
||||
<img src="${dashThumb(p.photo_path)}" data-img="${API}${p.photo_path}" loading="lazy" decoding="async" alt="">
|
||||
${p.caption ? `<div class="pcap">${esc(p.caption)}</div>` : ''}
|
||||
</div>`).join('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user