【问题标题】:Use cropped image with fallback in TypoScript in TYPO3 8在 TYPO3 8 中的 TypoScript 中使用带有后备功能的裁剪图像
【发布时间】:2018-02-02 14:20:27
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    我已在 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" />
    

    表现如预期

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多