Make the slide image description optional
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:
1 parent
8522918c75
commit
33c75e504f
4 files changed
+13
-38
No files matched your search
@@ -20,9 +20,6 @@ $posted = $request->is(['post', 'put', 'patch']);
|
||||
$hasImage = $slide->hasImage();
|
||||
// After a failed save the posted values are shown again.
|
||||
$alt = $posted ? (string)$request->getData('image_alt', '') : (string)$slide->image_alt;
|
||||
$decorative = $posted
|
||||
? filter_var($request->getData('image_decorative'), FILTER_VALIDATE_BOOLEAN)
|
||||
: ($hasImage && $slide->image_alt === '');
|
||||
$layout = $posted && in_array($request->getData('image_layout'), Slide::IMAGE_LAYOUTS, true)
|
||||
? (string)$request->getData('image_layout')
|
||||
: $slide->imageLayout();
|
||||
@@ -34,7 +31,6 @@ if ($slide->type === Slide::TYPE_CONTENT) {
|
||||
$layouts[Slide::IMAGE_FULL] = __('Bildschirm füllen (Bild so groß wie möglich)');
|
||||
}
|
||||
$imageError = $slide->getError('image');
|
||||
$altError = $slide->getError('image_alt');
|
||||
$maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
|
||||
?>
|
||||
<fieldset class="image-fields" data-image-fields>
|
||||
@@ -76,23 +72,13 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
||||
<div class="error-message" id="image-error"><?= h(implode(' ', (array)$imageError)) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="input text<?= $altError ? ' error' : '' ?>">
|
||||
<label for="image-alt"><?= __('Bildbeschreibung (für Screenreader)') ?></label>
|
||||
<div class="input text">
|
||||
<label for="image-alt"><?= __('Bildbeschreibung (optional)') ?></label>
|
||||
<input type="text" id="image-alt" name="image_alt" maxlength="<?= Slide::IMAGE_ALT_MAX ?>" autocomplete="off"
|
||||
value="<?= h($alt) ?>" placeholder="<?= h(__('z. B. Organigramm des Vereins')) ?>"
|
||||
aria-describedby="image-alt-hint<?= $altError ? ' image-alt-error' : '' ?>" <?= $altError ? 'aria-invalid="true"' : '' ?>>
|
||||
<p class="hint" id="image-alt-hint"><?= __('Pflicht, sobald ein Bild gesetzt ist – oder das Bild ist reine Dekoration.') ?></p>
|
||||
<?php if ($altError) : ?>
|
||||
<div class="error-message" id="image-alt-error"><?= h(implode(' ', (array)$altError)) ?></div>
|
||||
<?php endif; ?>
|
||||
aria-describedby="image-alt-hint">
|
||||
<p class="hint" id="image-alt-hint"><?= __('Kurz beschreiben, was zu sehen ist. Das hilft Menschen, die einen Screenreader nutzen. Leer lassen, wenn das Bild nur Dekoration ist.') ?></p>
|
||||
</div>
|
||||
<?= $this->Form->control('image_decorative', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Reine Dekoration (keine Beschreibung nötig)'),
|
||||
'value' => '1',
|
||||
'hiddenField' => false,
|
||||
'checked' => $decorative,
|
||||
]) ?>
|
||||
<fieldset class="scale-style image-fields__layout">
|
||||
<legend><?= __('Platzierung in der Präsentation') ?></legend>
|
||||
<?= $this->Form->radio('image_layout', array_map(
|
||||
|
||||
Reference in new issue
Block a user