0

How can I get the second image in template for news extension of GeorgeRinger in TYPO3.

I extend the showinpreview field with "show in teaser" and I want to acces the second image, or better the image where "show in teaser" was set, in the templatefile for the teaser.

If I debug the newsItem.mediaPreviews, there ist only one image, but I set two in the backend… so how can I get the other image.

Thanks

TYPO3: 9.5.14 news: 7.3.1

MonTea
  • 1,166
  • 1
  • 13
  • 30

1 Answers1

2

If you check out the model News you will see this:

public function getMediaPreviews()
{
    $configuration = [FileReference::VIEW_LIST_AND_DETAIL, FileReference::VIEW_LIST_ONLY];
    return $this->getMediaItemsByConfiguration($configuration);
}

This means that you only get those with the allowed types.


As a solution there are 2 options:

  • use {newsItem.getMedia} and check in the <f:for> for the value
  • extend the model with a custom getter method which returns the ones you need
Georg Ringer
  • 7,779
  • 1
  • 16
  • 34
  • The first solution seems to work, but it's {news.media} in fluid ;) Thanks - Now I'll try the second solution, i think it's better to have an own field with the teaser-images, preventing too mutch conditions in fluid. ;) – MonTea Mar 19 '20 at 10:21