Skip to content

Instantly share code, notes, and snippets.

@a-r-m-i-n
Last active July 30, 2020 14:02
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save a-r-m-i-n/ef22ed696403e583631a to your computer and use it in GitHub Desktop.
Save a-r-m-i-n/ef22ed696403e583631a to your computer and use it in GitHub Desktop.
How to render responsive images in fluid templates (dce example)
{namespace dce=ArminVieweg\Dce\ViewHelpers}
<f:layout name="Default" />
<f:section name="main">
<f:for each="{dce:fal(field:'images', contentObject:contentObject)}" as="image">
<!-- This is the normal unresponsive way -->
<f:image image="{image}" />
<!-- Here we referer to typoscript to render the responsive image -->
<f:cObject typoscriptObjectPath="lib.responsiveImage" data="{image.uid}"></f:cObject>
</f:for>
</f:section>
lib.responsiveImage = IMAGE
lib.responsiveImage {
file {
import.current = 1
treatIdAsReference = 1
}
sourceCollection < tt_content.image.20.1.sourceCollection
layout < tt_content.image.20.1.layout
layoutKey = {$styles.content.imgtext.layoutKey}
}
@a-r-m-i-n
Copy link
Author

@boscho87
Copy link

hmm that does not work for me :/ to old? is there a good solution for the current version ?

@chrpos
Copy link

chrpos commented Sep 14, 2015

Thank you, great hint!

@Scopestyle
Copy link

Is there a way to apply the same technique for section images?

<f:for each="{item.image -> dce:explode()}" as="imageUid">
    <f:image src="file:{imageUid}"/>                        
</f:for>

@Hummel-Mors
Copy link

I have exactly the same problem:

<f:for each="{item.image -> dce:explode()}" as="imageUid">
<f:image src="file:{imageUid}"/>
</f:for>

Is there any solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment