我正在寻找一种在TypoScript中获取IMG_RESOURCE对象的绝对路径的方法。由于baseUrl对我来说不是真正的解决方案,因此简单添加config.baseUrl = example.com
不是我接受的东西。
所以,我该如何解决这样的问题:
ogimage = FILES
ogimage{
references {
table = pages
uid.data = page:uid
fieldName = tx_csseo_og_image
}
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
file.height < plugin.tx_csseo.social.openGraph.image.height
file.width < plugin.tx_csseo.social.openGraph.image.width
# this needs to be generated with an absolute URL
stdWrap.dataWrap = <meta property="og:image" content="|" />
}
}
我自己找到了解决方案。问题的关键是根本不设置域。并且具有从FILES和IMG_RESOURCE对象呈现的绝对URL,以便能够调整图像的大小。
ogimage = FILES
ogimage{
references {
table = pages
uid.data = page:uid
fieldName = tx_csseo_og_image
}
renderObj = TEXT
renderObj {
typolink{
parameter.stdWrap{
cObject = IMG_RESOURCE
cObject{
file.import.data = file:current:uid
file.treatIdAsReference = 1
file.height < plugin.tx_csseo.social.openGraph.image.height
file.width < plugin.tx_csseo.social.openGraph.image.width
}
}
returnLast = url
forceAbsoluteUrl = 1
}
wrap = <meta property="og:image" content="|" />
}
}
这将通过IMG_RESOURCE生成调整大小的图像,然后通过typolink生成此生成图像的绝对URL,然后将其包装在元标记中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句