简体   繁体   中英

TYPO3 News: show first image in preview

I am using the News Extension from Georg Ringer in TYPO3 8.7.13.

If no image is selected for previews the extension shows a dummy image. Is it possible to use the first image from the article instead?

Thanks

Sure, you need to override the List/Item fluid partial. To do it, add

plugin.tx_news.view.partialRootPath = EXT:your_extension/Resources/Private/Partials/News/

in your typoscript constants.

Then copy the partial fluid files from news extension in your extension. You should have something like this :

在此处输入图片说明

In the News/List/Item.html modify this part

    <f:if condition="{settings.displayDummyIfNoMedia}">
            <div class="news-img-wrap">
                <span class="no-media-element">
                    <n:link newsItem="{newsItem}" settings="{settings}" title="{newsItem.title}">
                        <f:image src="{settings.list.media.dummyImage}" title="" alt="" maxWidth="{f:if(condition: settings.media.maxWidth, then: settings.media.maxWidth, else: settings.list.media.image.maxWidth)}" maxHeight="{f:if(condition: settings.media.maxHeight, then: settings.media.maxHeight, else: settings.list.media.image.maxHeight)}"/>
                    </n:link>
                </span>
            </div>
        </f:if>

to

         <div class="news-img-wrap">
            <n:link newsItem="{newsItem}" settings="{settings}" title="{newsItem.title}">
                <f:alias map="{mediaElement: '{newsItem.falMedia.0}'}">
                    <f:if condition="{mediaElement.originalResource.type} == 2">
                        <f:image image="{mediaElement}" title="{mediaElement.originalResource.title}" alt="{mediaElement.originalResource.alternative}" maxWidth="{f:if(condition: settings.media.maxWidth, then: settings.media.maxWidth, else: settings.list.media.image.maxWidth)}" maxHeight="{f:if(condition: settings.media.maxHeight, then: settings.media.maxHeight, else: settings.list.media.image.maxHeight)}"/>
                    </f:if>
                    <f:if condition="{mediaElement.originalResource.type} == 4">
                        <f:render partial="Detail/MediaVideo" arguments="{mediaElement: mediaElement}"/>
                    </f:if>
                    <f:if condition="{mediaElement.originalResource.type} == 5">
                        <f:image image="{mediaElement}" title="{mediaElement.originalResource.title}" alt="{mediaElement.originalResource.alternative}" maxWidth="{f:if(condition: settings.media.maxWidth, then: settings.media.maxWidth, else: settings.list.media.image.maxWidth)}" maxHeight="{f:if(condition: settings.media.maxHeight, then: settings.media.maxHeight, else: settings.list.media.image.maxHeight)}"/>
                    </f:if>
                </f:alias>
            </n:link>
        </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM