Adding alt and title attributes to images

It's always a good idea to add an alternative text to an image that is displayed on a web page. Users with screen readers (keyword accessibility) need this textual information and some users configured their browsers to not show any images (e.g. mobile devices). Besides, most of the major search engines use the alternative text of images as additional information when indexing a page.

To provide a description for an image, the attributes alt and title of the img src tag need to be used. When an image is inserted into a page via TypoScript's IMAGE content type, these attributes are not set by default.

By using the following TypoScript code, you can set both the alt and the title attributes:

TypoScript: 'alt' and 'title' for images

SETUP
temp.image_with_alttext = IMAGE
temp.image_with_alttext {
  file = fileadmin/images/picture-with-alt-and-title.jpg
  altText = ... text for 'alt' attribute ...
  titleText = ... text for 'title' attribute ...
}

If the 'titleText' option is omitted, the content of 'altText' will be used as the title attribute as well.

Comments for Adding alt and title attributes to images

Be the first to comment this article!


Add a comment


(will not be displayed, Gravatar is enabled)



(Fields marked with a * are mandatory)

Visitors found this page by searching for these keywords:

typoscript image title · typoscript image attribute · typoscript file alt tag · typoscript title -1 · typoscript image alt