Is there a way to resize and crop an image within a 'Text and Images' element using typoscript?
I have used this in the past to give custom wraps to an Images Only element by setting the image layout:
# Get default settings for images
temp.image < tt_content.image.20
# Define new layout
tt_content.image.20 = CASE
tt_content.image.20 {
key.field = layout
default < temp.image
1 < temp.image
100 < temp.image
100 {
imageStdWrap.dataWrap = <div class="gallery"><ul>|</ul></div>
renderMethod = ul
rendering {
ul {
oneImageStdWrap.dataWrap = <li>|</li>
}
}
layout.default.value = ###IMAGES###
}
}
# Set defaults also for TEXTPIC
tt_content.textpic.20 = < tt_content.image.20.default
Is there a way to perhaps modify this same technique to include a set width and height?
Keep in mind this will do only for CSC only. FSC uses fluid-templates instead of TypoScript.
But the usage should be the same: in FSC look for the appropriate partial, in CSC look for the IMAGE object (should be in temp.image for your example). Then you can find the usage of the width and height of the record or the default-max sizes for images.
There you can append an override with your values conditioned on your selected layout.
In FSC you can find the partial EXT:fluid_styled_content/Resources/Private/Partials/Mediagallery.html
, copy it, and enhance the paths.
At the end of that file you can find the section media
.
depending on your layout you can modify it like this:
<f:section name="media">
<f:if condition="{layout} == 1">
<f:then>
<f:media
file="{column.media}"
width="200c"
height="200c"
alt="{column.media.alternative}"
title="{column.media.title}"
/></f:then>
<f:else>
<f:media
file="{column.media}"
width="{column.dimensions.width}"
height="{column.dimensions.height}"
alt="{column.media.alternative}"
title="{column.media.title}"
/></f:else>
</f:if>
</f:section>
The CSC solution (for 7.6) would be to wrap the width (and height) attributes:
tt_content.image.20 {
maxW.override {
override = 200c
override.if {
equals.field = layout
value = 1
}
}
}
Attention! the field layout is used otherwise in 'text and image'. you might use another field (e.g. section_frame),
the construct with override the override is necessary to add to the existing functionality.