Make the slide image description optional
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

A missing description rejected the whole save and dropped the selected
file, which cannot be refilled in the form. The description is now an
optional hint for screen readers; empty means alt="". The "decorative"
checkbox is gone, it meant the same.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-15 13:56:27 +01:00
1 parent 8522918c75
commit 33c75e504f
4 files changed
+13 -38

No files matched your search

+3 -6
View File
@@ -415,15 +415,12 @@ class SlidesController extends AdminAppController
return $state;
}
// Without an image to describe, accessibility needs either a text or the explicit "decorative".
// The description is optional (recommended for screen readers); empty means alt="" (skipped by them).
// Never reject an upload for it: the file input cannot be refilled after a failed save.
$alt = mb_substr(trim((string)($data['image_alt'] ?? '')), 0, Slide::IMAGE_ALT_MAX);
$decorative = filter_var($data['image_decorative'] ?? false, FILTER_VALIDATE_BOOLEAN);
if (!$decorative && $alt === '') {
$errors['image_alt'] = __('Bitte beschreibe das Bild kurz (für Menschen mit Screenreader) oder markiere es als reine Dekoration.');
}
$layout = $data['image_layout'] ?? null;
$slide->patch([
'image_alt' => $decorative ? '' : $alt,
'image_alt' => $alt,
'image_layout' => in_array($layout, Slide::IMAGE_LAYOUTS, true) ? $layout : null,
], ['guard' => false]);
$this->setErrors($slide, $errors);