Add optional images to slides
CI / Deploy / PHP 8.4 (push) Successful in 1m10s
CI / Deploy / PHP 8.5 (push) Successful in 1m16s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Slides (except YouTube) can carry one image. Uploads are validated, rotated
by EXIF orientation, scaled to 1600 px and stored as WebP outside webroot,
which also strips camera metadata. Images have an alt text (or are marked
decorative) and a layout: top, side or full screen (content slides).

Files are removed after the commit when a slide is deleted or its image is
replaced, with the poll, and `bin/cake images_cleanup` sweeps leftovers.
Duplicated slides get their own file. Docker image gains gd with WebP.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-14 23:17:37 +01:00
1 parent 8c7818ee40
commit a395b50894
30 files changed
+1705 -11

No files matched your search

+22
View File
@@ -694,6 +694,19 @@ body.present {
.stage--video .stage__description { font-size: clamp(1rem, 1.6vw, 1.3rem); }
.stage--content .stage__description { color: var(--text); font-size: clamp(1.3rem, 2.6vw, 2.2rem); }
.stage__results { font-size: clamp(1rem, 1.8vw, 1.5rem); margin-top: 2vh; }
/* slide images: above the results (default), next to the text (side) or as large as possible (full) */
.stage__image { margin: 1vh auto 0; }
.stage__image img { display: block; max-width: 100%; max-height: 38vh; width: auto; height: auto; margin: 0 auto; object-fit: contain; border-radius: 8px; }
.stage--img-side .stage__main { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-auto-rows: min-content; align-content: center; column-gap: 4vw; }
.stage--img-side .stage__main > * { grid-column: 2; }
.stage--img-side .stage__main > .stage__image { grid-column: 1; grid-row: 1 / span 5; align-self: center; margin: 0; }
.stage--img-side .stage__image img { max-height: 68vh; }
.stage--img-full .stage__image img { max-height: 66vh; }
.stage--img-full .stage__question { font-size: clamp(1.5rem, 3vw, 2.6rem); }
@media (max-width: 800px) {
.stage--img-side .stage__main { display: flex; }
.stage--img-side .stage__image img { max-height: 38vh; }
}
.stage .bar__track { height: 1.1em; }
/* scale on stage: big average next to a compact donut */
.stage .scale-results__row { gap: 2vw; }
@@ -779,3 +792,12 @@ body.present {
body:has(dialog[open]) { overflow: hidden; }
.slide-item__actions form { display: contents; }
.slide-item__actions button:disabled, .admin-head__actions button:disabled { opacity: .6; cursor: progress; }
/* slide images: participant page and slide form */
.slide-image { margin: 1em 0; }
.slide-image img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 8px; }
.image-fields, .image-fields__layout { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.image-fields > legend { font-weight: 600; padding: 0; margin-bottom: .5em; }
.image-fields__layout > legend { padding: 0; margin-bottom: .25em; }
.image-fields__current { margin: 0 0 .75em; }
.image-fields__current img { display: block; max-width: 100%; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
+29
View File
@@ -1293,6 +1293,33 @@
}
}
/** Shows the image of the slide (layout: top | side | full via stage--img-* classes); the <img> stays while the file stays. */
function renderImage(slide) {
var figure = q('[data-image]');
var image = slide && slide.image ? slide.image : null;
['top', 'side', 'full'].forEach(function (layout) {
root.classList.toggle('stage--img-' + layout, !!image && image.layout === layout);
});
figure.hidden = !image;
if (!image) {
figure.textContent = '';
return;
}
var img = figure.querySelector('img');
if (!img) {
img = document.createElement('img');
figure.appendChild(img);
}
if (img.getAttribute('src') !== image.url) {
img.setAttribute('src', image.url);
}
img.setAttribute('alt', image.alt || '');
if (image.width && image.height) {
img.setAttribute('width', image.width);
img.setAttribute('height', image.height);
}
}
function render(newState) {
var serialized = JSON.stringify(newState);
if (serialized === last) {
@@ -1332,6 +1359,7 @@
: 'Drücke → um zu starten.');
q('[data-results]').innerHTML = '';
renderMedia(null);
renderImage(null);
root.classList.remove('stage--video');
q('[data-voting]').hidden = true;
setText('[data-participants]', '');
@@ -1352,6 +1380,7 @@
root.classList.toggle('stage--content', !slide.isInteractive);
root.classList.toggle('stage--video', slide.type === 'youtube');
renderMedia(slide);
renderImage(slide);
root.classList.toggle('stage--closed', closed);
root.classList.toggle('stage--qa', !!qaStage);