tt_news: Wrap images depending on amount of images

531 views Asked by At

I have a list view of tt_news news items. To this news items, images can be uploaded.

What I want to do:

If the user uploads one image, this image should be displayed large between item title and content. If the user uploads multiple images, this images should be displayed smaller and all together.

Is it somehow possible to display images in different size and different wrappign depending on their amount?

1

There are 1 answers

0
lorenz On BEST ANSWER

What you want is not easily possible. A working out-of-the-box function is to use EXT:rgnewsce. With that extension you can add normal content elements to news and therefore you can set some image settings (number of columns, width). You could even manipulate the results with TypoScript.

The most flexible possibility is to use a custom imageMarkerFunc. If you register a custom imageMarkerFunc, you basically get all the image data and give back a filled ###NEWS_IMAGE### marker. A possible drawback is that also some lightbox extensions use the same function, so you might have conflicts.

You can call the function like this (in your tt_news TypoScript):

includeLibs.imageMarkerFunc = fileadmin/admin/scripts/tt_news_imageMarkerFunc.php
plugin.tt_news.imageMarkerFunc = user_imageMarkerFunc

(Where user_imageMarkerFunc is the name of the function you call. User-defined functions must be prefixed with user_, if you put it in your own extension, you might also use tx_.)

An example can be found in the tt_news source code:

https://git.typo3.org/TYPO3v4/Extensions/tt_news.git/blob/HEAD:/res/example_imageMarkerFunc.php

For your information, the templating of EXT:news is based on Fluid what would make your life easier. You can count images, style them depending on their count etc.