简体   繁体   English

在TYPO3 8中的TypoScript中将裁切后的图像与后备一起使用

[英]Use cropped image with fallback in TypoScript in TYPO3 8

This TS code always produces a 600x400px image: 此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
      }
  }

If I remove 如果我删除

      file.width=600c
      file.height=400c

then the cropped image from the crop wizard will be used. 然后将使用裁剪向导中的裁剪图像。

But I need both (it's an upgrade of an existing site): if available, the cropped image is used, but if not, the given height and width are used. 但是我两者都需要(这是对现有站点的升级):如果可用,则使用裁剪后的图像,但如果不使用,则使用给定的高度和宽度。

How do I use the "file:current:crop" part to override width & height only if given? 仅在给定的情况下,如何使用“ file:current:crop”部分覆盖宽度和高度? Or how do I set a fallback? 或如何设置后备广告? something like... 就像是...

file.crop.data = file:current:crop // fallback...

I've moved to FLUIDTEMPLATE in the renderObj: 我已经移到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
    }
  }
}

(The FilesProcessor is required) (FilesProcessor是必需的)

And then in the template 然后在模板中

<img src="<f:uri.image image="{teaserimages.0}" width="600c" height="400c" />

Behaves as expected 表现预期

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM