问题
This TS code always produces a 600x400px image:
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
wrap = <div class="teaser-image">|</div>
file.import.data = file:current:originalUid // file:current:uid
file.crop.data = file:current:crop
file.width=600c
file.height=400c
}
}
If I remove
file.width=600c
file.height=400c
then the cropped image from the crop wizard will be used.
But I need both (it's an upgrade of an existing site): if available, the cropped image is used, but if not, the given height and width are used.
How do I use the "file:current:crop" part to override width & height only if given? Or how do I set a fallback? something like...
file.crop.data = file:current:crop // fallback...
回答1:
I've moved to FLUIDTEMPLATE in the renderObj:
renderObj = FLUIDTEMPLATE
renderObj {
file = path/to/templates/content/teaser.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
references.table = tt_content
as = teaserimages
}
}
}
(The FilesProcessor is required)
And then in the template
<img src="<f:uri.image image="{teaserimages.0}" width="600c" height="400c" />
Behaves as expected
来源:https://stackoverflow.com/questions/48584655/use-cropped-image-with-fallback-in-typoscript-in-typo3-8