[英]Use cropped image with fallback in TypoScript in TYPO3 8
此TS代碼始終生成600x400px的圖片:
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
}
}
如果我刪除
file.width=600c
file.height=400c
然后將使用裁剪向導中的裁剪圖像。
但是我兩者都需要(這是對現有站點的升級):如果可用,則使用裁剪后的圖像,但如果不使用,則使用給定的高度和寬度。
僅在給定的情況下,如何使用“ file:current:crop”部分覆蓋寬度和高度? 或如何設置后備廣告? 就像是...
file.crop.data = file:current:crop // fallback...
我已經移到renderObj中的FLUIDTEMPLATE:
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
}
}
}
(FilesProcessor是必需的)
然后在模板中
<img src="<f:uri.image image="{teaserimages.0}" width="600c" height="400c" />
表現預期
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.