Empty alt text on Magento 2 CMS banners: how do you use the page title and a custom override?

2 min read

Three silver plaques with mountain reliefs. The middle plaque has a blank violet strip and the right one has an apricot corner.

Start with the banner’s role on the CMS page. When an image provides information, its alt text should convey that information. Use the page title when it accurately describes the image in context.

Check which pattern takes precedence

In Image Alt From Attributes 1.0.1, a nonempty Images Alt Tag Structure field on the CMS page takes precedence over the CMS pattern for the current store view. Both fields accept custom text and the {page_title} and {content_heading} tokens. The tested version fills an existing alt="". Add a missing attribute in the editor. Image Alt From Attributes documentation

Keep alt text empty for decoration

Keep alt="" on an image that serves only as decoration. The CMS pattern can also fill an intentionally empty value. To retain decorative images’ empty alt text, keep the store view’s CMS pattern and the page field empty. Add alt text directly to informative images, or use page-specific patterns on other pages that need them. W3C guidance on decorative images

Three CMS page checks
Page and image roleTest settingExpected alt text
Roller blind installation. The banner depicts installation.CMS pattern {page_title}. The page field is empty.Roller blind installation
Roller blind parts. The content heading is “Mounting bracket”.Page field contains {content_heading} – underside view.Mounting bracket – underside view
About us. The image is a decorative pattern.Separate test with the CMS pattern and the page field empty.alt=""

Read the actual alt attribute after saving

Open each page in the intended store view and inspect the banner’s attribute in developer tools. If a pattern gives several different images the same text, enter a precise alternative on each informative image. For decoration, check that the attribute exists in the HTML and is empty.

Kowal Image Alt From Attributes for Magento 2 · Product image alt text from catalog data

Previous Next

KOWAL.BLOG

Choose your language

Available versions open the corresponding page. More languages are being prepared.

English (UK) Français Deutsch Español Italiano Português Nederlands Svenska Dansk Norsk Suomi Lietuvių Latviešu Eesti Čeština Slovenčina Magyar Română Български Ελληνικά Slovenščina Hrvatski Polski English (US)