diff --git a/AGENTS.md b/AGENTS.md index 817a339..84993e5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -215,7 +215,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures Ablage `{Plenario.images.path}/{poll_id}/{24 Hex}.webp` (Standard `data/uploads`, Docker `/data/uploads`) **außerhalb von `webroot/`**, ausgeliefert über `participate:image` (`/p/{code}/img/{file}`, auch für Presenter und Einbettung; nur Dateien dieser Umfrage, `immutable` gecacht, kein Cookie). Jedes neue Bild bekommt einen neuen Namen → neue URL, ersetzte Bilder sind sofort 404. - Alt-Text ist Pflicht (`image_alt`), außer „Reine Dekoration“ (`image_alt = ''`). Layout `image_layout` (`top`|`side`|`full`, `full` nur + Die Bildbeschreibung (`image_alt`) ist optional (leer = `alt=""`) und darf nie zur Ablehnung führen: das Dateifeld lässt sich nach einem Fehler nicht neu füllen. Layout `image_layout` (`top`|`side`|`full`, `full` nur Inhaltsfolien, `null` = Standard je Typ: Inhaltsfolie `side`, sonst `top`; `Slide::imageLayout()`); `side` gilt nur für die Bühne (CSS `stage--img-*`), Teilnehmende sehen das Bild immer oben (`element/slide_image`). Kontingent `Plenario.images.maxPerPoll` Folien mit Bild. Im State steht `slide.image` = `{url, alt, layout, width, height}` (`PollStateService::slidePayload()`). diff --git a/src/Controller/SlidesController.php b/src/Controller/SlidesController.php index ebd6585..203ff7e 100644 --- a/src/Controller/SlidesController.php +++ b/src/Controller/SlidesController.php @@ -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); diff --git a/templates/element/slide_image_fields.php b/templates/element/slide_image_fields.php index 9662b95..4196c7a 100644 --- a/templates/element/slide_image_fields.php +++ b/templates/element/slide_image_fields.php @@ -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); ?>
@@ -76,23 +72,13 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
-
- +
+ > -

- -
- + aria-describedby="image-alt-hint"> +

- Form->control('image_decorative', [ - 'type' => 'checkbox', - 'label' => __('Reine Dekoration (keine Beschreibung nötig)'), - 'value' => '1', - 'hiddenField' => false, - 'checked' => $decorative, - ]) ?>
Form->radio('image_layout', array_map( diff --git a/tests/TestCase/Controller/SlideImageTest.php b/tests/TestCase/Controller/SlideImageTest.php index c9e1ec6..4f79070 100644 --- a/tests/TestCase/Controller/SlideImageTest.php +++ b/tests/TestCase/Controller/SlideImageTest.php @@ -77,27 +77,19 @@ class SlideImageTest extends TestCase $this->assertSame(Slide::IMAGE_TOP, $choice->imageLayout(), 'full exists for content slides only'); } - public function testImageNeedsAltTextOrDecorativeFlag(): void + public function testImageDescriptionIsOptional(): void { [$poll, $token] = $this->createPoll(); $this->postWithImage("/admin/$token/slides/add?type=content", [ 'type' => 'content', - 'question' => 'Ohne Text', + 'question' => 'Ohne Beschreibung', ], $this->makeImage()); - $this->assertResponseOk(); - $this->assertResponseContains('Bitte beschreibe das Bild'); - $this->assertSame(0, $this->slidesTable()->find()->where(['poll_id' => $poll->id])->count()); - $this->assertSame([], $this->storedImages($poll->id), 'no file left behind'); - - $this->postWithImage("/admin/$token/slides/add?type=content", [ - 'type' => 'content', - 'question' => 'Dekoration', - 'image_decorative' => '1', - ], $this->makeImage()); + $this->assertRedirect(['_name' => 'admin', 'token' => $token]); $slide = $this->slidesTable()->find()->where(['poll_id' => $poll->id])->firstOrFail(); - $this->assertSame('', $slide->image_alt); $this->assertTrue($slide->hasImage()); + $this->assertSame('', $slide->image_alt); + $this->assertSame([$slide->image], $this->storedImages($poll->id)); } public function testRejectsFilesThatAreNoImages(): void