在我的菜单中,我使用脚本来检索页面资源中加载的图像。
现在我需要制作它,以便将图像调整大小/裁剪为完全正确的尺寸。我在哪里可以添加宽度和高度以使其工作?
NO {
wrapItemAndSub = <li>|</li>
stdWrap.cObject = COA
stdWrap.cObject {
10 = TEXT
10.field = title
10.wrap = <span>|</span>
20 = FILES
20 {
# Get the images related to the current page
references {
table = pages
fieldName = media
}
# Render each image and wrap it as appropriate
renderObj = TEXT
renderObj {
typolink {
parameter.data = file:current:publicUrl
forceAbsoluteUrl = 1
returnLast = url
}
wrap = |,
}
stdWrap {
# Take only the first image if several are defined
listNum = 0
# Use default image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = fileadmin/templates/example/images/placeholder.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <div><img src="|" /></div>
}
}
}
}
答案 0 :(得分:2)
如果您想调整图片大小,请将renderObj = TEXT
改为renderObj = IMG_RESOURCE
示例:
NO {
wrapItemAndSub = <li>|</li>
stdWrap.cObject = COA
stdWrap.cObject {
10 = TEXT
10.field = title
10.wrap = <span>|</span>
20 = FILES
20 {
# Get the images related to the current page
references {
table = pages
fieldName = media
}
# Render each image and wrap it as appropriate
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
file.width = 250c
file.height = 250c
wrap = |,
}
stdWrap {
# Take only the first image if several are defined
listNum = 0
# Use default image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = fileadmin/templates/example/images/placeholder.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <div><img src="|" /></div>
}
}
}
要仅渲染一个图像,您不应首先列出所有图像。使用maxItems
的{{1}}设置,然后从FILES
移除listNum
。
stdWrap
答案 1 :(得分:0)
我认为您需要使用GIFBUILDER。 GIFBUILDER会将图像传递给ImageMagick,它将帮助您根据需要剪切/缩放/缩放图像。
像
这样的东西lib.image = IMAGE
lib.image {
file = GIFBUILDER
file {
#use the c in XY to crop
XY = 1024c,768c
format = jpg
10 = IMAGE
10.file = fileadmin/image.jpg
}
}
您可以在此处阅读有关Gifbuilder的更多信息:
https://docs.typo3.org/typo3cms/TyposcriptReference/Gifbuilder/Index.html