在TYPO3 8的TypoScript中使用带有后退的裁剪图像

时间:2018-02-02 14:20:27

标签: typo3 typoscript typo3-8.x typo3-8.7.x

此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”部分覆盖宽度&amp;高度只有给定?或者我如何设置后备?类似......

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

1 个答案:

答案 0 :(得分: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
    }
  }
}

(需要FilesProcessor)

然后在模板中

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

按预期行事