Markus Michalski FAQ

Sylius Media Alt Text: Configuration

Configuring the Sylius Media Alt Text plugin: the global switch in the admin, maintaining alt texts per image and language, decorative images and the backfill command with all its options.

Deutsche Version

Back to overview

Sylius Media Alt Text: Configuration

This documentation always describes the latest published version.

The plugin has no YAML configuration and reads no environment variables. There is exactly one setting, and it lives in the admin.

Setting in the admin

Admin sidebar > MMKreativ Plugins > Image Alt Texts, available at /admin/media-alt-text/settings (the prefix follows your configured admin path). Access is granted to anyone with ROLE_ADMINISTRATION_ACCESS.

Setting Default Description
Output alt texts on Turns the output in the Storefront and Shop API on or off

The setting applies to the whole shop, not per channel and not per language.

When the output is off:

Headless clients read the state through GET /api/v2/shop/media-alt-text-settings, see Shop API.

Maintaining alt texts

Every product image, category image and admin avatar shows the alt text editor in its own image card:

For taxons, the editor sits to the right of each image; for products, in every image card of the media section.

How a text is chosen

  1. Text in the requested language
  2. Text in the shop's default language
  3. The name of the product or category in the requested language, or failing that a name in another language (for avatars the first and last name, otherwise the username)

An image counts as decorative as soon as one of its rows is marked that way. In that case the alt text is empty (alt=""), and the fallback does not apply.

A decorative image without text stores an empty row in the default language, because the flag is attached to the row.

Backfill command

mmd:media-alt-text:backfill pre-fills missing texts with the product or category name, so editors have something to refine.

Option Default Description
--type, -t product, taxon Image type, can be given multiple times. Allowed values are product, taxon and avatar
--locale, -l all enabled shop languages Language, can be given multiple times
--force off Also replaces existing texts
--dry-run off Report only, write nothing
bin/console mmd:media-alt-text:backfill --dry-run
bin/console mmd:media-alt-text:backfill --locale=de_DE --type=product

The command:

A product name is a starting point for editors, not an image description. Review the generated texts before you rely on them.

Practical examples

New shop, maintaining texts gradually: Install the plugin and do nothing else. Images without text keep outputting the product name, and editors add texts as they edit the products.

Existing shop with many products: Do a dry run first, then fill only the default language:

bin/console mmd:media-alt-text:backfill --dry-run
bin/console mmd:media-alt-text:backfill --locale=de_DE

Temporarily hiding the plugin: Turn off the "Output alt texts" switch. Nothing is lost, the fields in the admin disappear and the shop behaves as before.