【问题标题】:Get url of processed image in TYPO3获取 TYPO3 中处理后图像的 url
【发布时间】:2018-05-16 06:45:36
【问题描述】:

我需要从 TYPO3 获取处理后图像的 URL。图像放置在自定义内容元素中并由用户修改(例如裁剪)。

我能够获取原始文件 URL,但我需要处理后的图像 URL(来自 file_processedImages 表)。

这是我的 TS:

# <------------ Speakers -------- 
tt_content.speakers = FLUIDTEMPLATE
tt_content.speakers {
file = EXT:cce/Resources/Speakers.html
variables {
    images = FILES
    images {

        references {
            table = tt_content
            fieldName = image
        }
        renderObj = COA
        renderObj {

            10 = TEXT
            10 {
                data = file:current:uid
                treatIdAsReference = 1
                wrap = |,
            }

            20 = TEXT 
            20 {
                data = file:current:publicUrl
                treatIdAsReference = 1
                wrap = |###
            }

            30 = TEXT 
            30 {
                data = file:current:title
                wrap = |,
            }

            40 = TEXT 
            40 {
                data = file:current:description
                htmlSpecialChars = 1
            }
        }       
    }   
}

}

我认为引用表总是作为 tt_content 上的子加载。 这意味着我应该能够从这样的引用图像中读取publicUrl

data = file:current:publicUrl
treatIdAsReference = 1

【问题讨论】:

    标签: typo3 typoscript typo3-7.6.x


    【解决方案1】:

    也许您应该使用 FilesProcessor 来获取 Extbase 模型并在 Fluid 中使用它? 见:https://docs.typo3.org/typo3cms/TyposcriptReference/7.6/ContentObjects/Fluidtemplate/#dataprocessing

    【讨论】:

    • 已经试过了,结果一样,返回的是原始图片的URL,不是处理后的...
    【解决方案2】:

    正如 Thomas 所写,我还建议在您的 FLUIDTEMPLATE 中使用 FilesProcessor:

    tt_content.speakers = FLUIDTEMPLATE
    tt_content.speakers {
    file = EXT:cce/Resources/Speakers.html
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        10 {
            references.fieldName = image
        }
    }
    

    在您的流体模板中,您可以访问原始文件(未处理)的公共 URL,或者在应用任何裁剪或 maxHeight 等时获取处理后的 URL:

    <f:for each="{files}" as="file">
        <p>Public URL: {file.originalFile.publicUrl}</p>
        <p>Processed URL: <f:uri.image image="{file}" height="{data.imageheight}" width="{data.imagewidth}" /></p>
        <hr />
    </f:for>
    

    【讨论】:

    • 好的,现在它适用于这个例子,所以我一定是我的网站上的一个错误。为托马斯点赞。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-16
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    相关资源
    最近更新 更多