0

I've set in my Constants

styles.content.textmedia.maxW = 400
styles.content.textmedia.maxWInText = 400
styles.content.imgtext.maxW = 800

and tried a simple

<f:image src="..."></f:image>

without any params and on the frontend the image is still rendered on its original width ignoring my maxW constants

The original problem was to set different maxW for each column in gridelements which also did not work for fluid content. So i tried to break it down to the simplest maxW setting and even that is not working.

If i take the Text & Image contentelement, it works as expected so i assume, the system is behaving correctly but for any reason fluid images are ignoring the setting?!

Is there anything i do wrong or is there something missing which sets the maxW for f:image? I cant set the maxW in the f:image directly cause it may be located in different columns with different sizes, so i have to set it outside of the f:image tag.

Update: The main target was to be able to use gridelements as the gridengine and using dce for creating content elements while the elements should knew about the column widths, they are located in to scale images properly.

With the help of Mikel Wohlschlegel i got the missing hint, to fix my problem.

Chris
  • 11
  • 3

2 Answers2

0

Short anwer:

The image viewhelper does not automatically apply any dimensions defined in the constants. f:image is part of ext:fluid, the constants you set are part of ext:fluid_styled_content. The image viewhelper always needs a width or a maxWidth argument if you want to set one. You need to pass your constants to the frontend.

Long answer:

You can see, how it is done in fluid_styled_content:

Have a look into: typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/Image.typoscript A DataProcessor passes this constants to the GalleryProcessor

tt_content.image {
templateName = Image
dataProcessing {
    20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor
    20 {
        maxGalleryWidth = {$styles.content.textmedia.maxW}
        maxGalleryWidthInText = {$styles.content.textmedia.maxWInText}
    }
}

and are passed through to the frontend as {column.dimensions} See typo3/sysext/fluid_styled_content/Resources/Private/Partials/Media/Gallery.html

<f:render partial="Media/Type" arguments="{file: column.media, dimensions: column.dimensions, data: data, settings: settings}" />

to finally gets applied as width argument in typo3/sysext/fluid_styled_content/Resources/Private/Partials/Media/Rendering/Image.html

<f:media class="image-embed-item" file="{file}" width="{dimensions.width}" height="{dimensions.height}" alt="{file.alternative}" title="{file.title}" />
Mikel Wohlschlegel
  • 1,364
  • 1
  • 11
  • 23
  • so this means, everything behaves as expected and there is no simple way to use the set maxw within a regular fluid f:image? Any idea to pass this information to the contentelement instead of doing all math in the element again? – Chris Feb 18 '20 at 07:51
  • better said i need to set a maxw in gridelements column settings to make sure an image in an custom element is getting resized correctly to fit in the column. i did it that way: https://stackoverflow.com/questions/42088137/set-maximagewidth-for-images-within-gridelements-col-using-fluid-styled-content but its also not respected by f:image due to the same problem i guess. :) – Chris Feb 18 '20 at 08:20
  • Sure, there is an easy way to pass settings to the view :-) Can you give me some more information? Where do you call this viewhelper? Is it in a template of a plugin? Or a content element, which gets processed by fluid_styled_content? Please add the information to your question above. – Mikel Wohlschlegel Feb 18 '20 at 08:47
  • i just found https://fluidtypo3.org/viewhelpers/vhs/master/Variable/Register/GetViewHelper.html which can read the register which i fill with the column width in the gridelements configuration – Chris Feb 18 '20 at 08:56
0

Solution:

gridelements config

tt_content.gridelements_pi1.20.10.setup {

  default < lib.gridelements.defaultGridSetup
  default {
        columns {
            default {
                renderObj = COA
                renderObj {
                    10 = LOAD_REGISTER
                    10.padding1.cObject = TEXT
                    10.padding1.cObject.data = field:parentgrid_flexform_padding1
                    10.padding2.cObject = TEXT
                    10.padding2.cObject.data = field:parentgrid_flexform_padding2
                    10.padding3.cObject = TEXT
                    10.padding3.cObject.data = field:parentgrid_flexform_padding3
                    10.colMaxWidth.cObject = CASE
                    10.colMaxWidth.cObject {
                        key.data = field:parentgrid_flexform_grid
                        default = TEXT
                        default.value = 1224
                        default.prioriCalc = 1
                    }
                    20.image.dataProcessing.20.maxGalleryWidth.data = register:colWidth
                    20.image.dataProcessing.20.maxGalleryWidthInText.data = register:colWidth

                    30 = RESTORE_REGISTER
                }
            }
        }
    }

  3 < .default
  3 {
    cObject = FLUIDTEMPLATE
    cObject {
      file = templates/gridelements/html/3columns.html
    }    
    columns {
      default.renderObj.10.colMaxWidth.cObject {
                default.value = 1224/100*33

                grid-20 = TEXT
                grid-20.value = 1224/100*20
                grid-20.prioriCalc = 1            
                grid-25 = TEXT
                grid-25.value = 1224/100*25
                grid-25.prioriCalc = 1                      
                grid-32 = TEXT
                grid-32.value = 1224/100*32
                grid-32.prioriCalc = 1                      
            } 
            0 < .default
            0.renderObj.10.colWidth.cObject = TEXT
            0.renderObj.10.colWidth.cObject {
                data = register:colMaxWidth
                stdWrap.dataWrap = | - {register:padding1} - {register:padding1}
                prioriCalc = 1
            }
            1 < .default
            1.renderObj.10.colWidth.cObject = TEXT
            1.renderObj.10.colWidth.cObject {
                data = register:colMaxWidth
                stdWrap.dataWrap = | - {register:padding2} - {register:padding2}
                prioriCalc = 1
            }
            2 < .default
            2.renderObj.10.colWidth.cObject = TEXT
            2.renderObj.10.colWidth.cObject {
                data = register:colMaxWidth
                stdWrap.dataWrap = | - {register:padding3} - {register:padding3}
                prioriCalc = 1
            }           
        }
    }

in dce fluid than i can use

{namespace vhs=FluidTYPO3\Vhs\ViewHelpers}
{vhs:variable.register.get(name: 'colWidth')}

to access this register value.

Chris
  • 11
  • 3