0

此 TS 代码始终生成 600x400 像素的图像:

  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...
4

1 回答 1

0

我已在 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
    }
  }
}

(需要文件处理器)

然后在模板中

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

表现如预期

于 2018-02-04T15:36:12.570 回答