Search code examples
typo3typo3-9.x

get altText in renderObject in typoscript


i have the following typoscript which works as expected:

table = tx_news_domain_model_news
select {
    selectFields = tx_news_domain_model_news.*, rand()
    pidInList = 111
    max = 1
    orderBy = rand()
    languageField = sys_language_uid
}
renderObj = COA
renderObj {
    10 = FILES
    10 {
        references {
            table = tx_news_domain_model_news
            uid.data = uid
            fieldName = fal_media
        }
        renderObj = IMAGE
        renderObj {
            wrap = <div class="news-list-item__image">|</div>
            file.import.data = file:current:originalUid
            file.width = 600c
            file.height = 345c
        }
    }
    ....

but i need an alt attribute for the image too and don`t know how to achieve this:

           renderObj {
            wrap = <div class="news-list-item__image">|</div>
            file.import.data = file:current:originalUid
            file.width = 600c
            file.height = 345c
            altText = ?????
        }

Is there a possibility to get the alt attribute here?

Thanks!


Solution

  • This should work:

    renderObj {
      // your code
      titleText.data = file:current:title
      altText.data = file:current:alternative
    }