WPML

Overview of the Issue

You might have a missing ALT tag for the image flag in the Language Switcher.

This is not a bug and is by design.

It is to improve Language Switcher accessibility for screen readers. The ALT tag for the image is not added if the anchor tag already has a title attribute. If an alt attribute is also added then a screen reader for a visually impaired user would indicate that there are two items here and would repeat the language twice (opens in a new tab). This is done according to the WCAG2.1 AA (opens in a new tab) issues:

If you want to have an ALT tag on the flag image then you can use the following workaround but it is not recommended if you want to follow the Web Content Accessibility Guidelines.

Workaround

This issue is fixed in WPML 4.7. Updating solves it on your site, so you only need this workaround if you can’t update yet.

Go to the ../wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/ directory and edit the class-wpml-ls-model-build.php file.

In it, change the following code from:

$ret[ $code ]['flag_alt']   = ( $display_name || $display_native ) ? '' : $data['translated_name'];

to:

$ret[ $code ]['flag_alt']   = ( $display_name || $display_native ) ? $data['native_name'] : $data['translated_name'];

Alternatively, you can also consider to configure a language switcher with flags only, in that way it will display the ALT.

Still Seeing This Issue?

If updating doesn’t fix it, ask a support question and we’ll look into it with you.

Ask a support question

All known issues