Sylius Media Alt Text: Shop API
Shop API of the Sylius Media Alt Text plugin: the alt field on product and category images, the media-alt-text-settings endpoint for headless clients, and the behavior when the output is switched off.
Sylius Media Alt Text: Shop API
This documentation always describes the latest published version.
The plugin works in both modes: the Storefront outputs the text through Twig, the Shop API through an additional field on every image.
graph LR
A["Storefront template"] --> C["Alt text resolver"]
B["Shop API request"] --> C
C --> D{"Output enabled?"}
D -->|No| E["Same as without the plugin"]
D -->|Yes| F["Text, decorative or fallback"]
F --> G["Twig alt attribute"]
F --> H["JSON field alt"]
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/api/v2/shop/media-alt-text-settings |
Returns whether the output is enabled |
GET |
existing Shop API resources with images | Every image additionally carries alt |
The plugin ships only the settings endpoint as its own resource. All other images (e.g. in /api/v2/shop/products/{code}) get the field through a serializer hook.
The alt field
Every product and category image that the Shop API returns carries alt, resolved for the language of the request:
{
"type": "main",
"path": "ab/cd/mug.jpg",
"alt": "A blue mug on a table"
}
- A decorative image returns
"alt": "". - Without maintained text the fallback applies (name of the product or category).
- If the output is turned off, the
altfield is omitted entirely. - The Shop API does not return
decorativeandaltTexts; they belong to the Admin API.
Settings endpoint for headless clients
curl -s https://shop.example.com/api/v2/shop/media-alt-text-settings -H 'Accept: application/json'
{ "active": true }
The only field is active. A headless frontend can use it to tell whether it should trust the alt field. The endpoint also reports false when the plugin's table is still missing (setup command not yet run).
Error format
The plugin's Shop endpoints are read-only. There are no custom error responses; the standard API Platform responses apply. Write errors (422) concern only the Admin API.