扩展中的 TYPO3 FAL 图像 [英] TYPO3 FAL images in extension

查看:27
本文介绍了扩展中的 TYPO3 FAL 图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里阅读了很多关于 TYPO3 中的 FAL 图像的帖子.
我已经更新到 TYPO3 v10,现在我需要用 FAL 渲染我的图像.
我找不到从零开始工作的解决方案.
我在自定义 Fluid+Extbase 扩展中使用它.

I've read a lot of posts here about FAL images in TYPO3.
I've updated to TYPO3 v10 and now I need to render my Images with FAL.
I can't find a solution to get it from zero to work.
I use this at a custom Fluid+Extbase extension.

我拥有的是 FlexForm:

What I've got is the FlexForm:

                <settings.image>
                    <TCEforms>
                        <label>Headerbild</label>
                        <config>
                            <type>inline</type>
                            <maxitems>1</maxitems>
                            <foreign_table>sys_file_reference</foreign_table>
                            <foreign_table_field>tablenames</foreign_table_field>
                            <foreign_label>uid_local</foreign_label>
                            <foreign_sortby>sorting_foreign</foreign_sortby>
                            <foreign_field>uid_foreign</foreign_field>
                            <foreign_selector>uid_local</foreign_selector>
                            <foreign_selector_fieldTcaOverride>
                                <config>
                                    <appearance>
                                        <elementBrowserType>file</elementBrowserType>
                                        <elementBrowserAllowed>gif,jpg,jpeg,png,svg</elementBrowserAllowed>
                                    </appearance>
                                </config>
                            </foreign_selector_fieldTcaOverride>
                            <foreign_types type="array">
                                <numIndex index="0">
                                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                                </numIndex>
                                <numIndex index="2">
                                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                                </numIndex>
                            </foreign_types>
                            <foreign_match_fields>
                                <fieldname>image</fieldname>
                            </foreign_match_fields>
                            <appearance type="array">
                                <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                                <headerThumbnail>
                                    <field>uid_local</field>
                                    <height>64</height>
                                    <width>64</width>
                                </headerThumbnail>
                                <enabledControls>
                                    <info>1</info>
                                    <new>0</new>
                                    <dragdrop>0</dragdrop>
                                    <sort>1</sort>
                                    <hide>0</hide>
                                    <delete>1</delete>
                                    <localize>1</localize>
                                </enabledControls>
                                <createNewRelationLinkTitle>LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference</createNewRelationLinkTitle>
                            </appearance>
                            <behaviour>
                                <localizationMode>select</localizationMode>
                                <localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
                            </behaviour>
                            <overrideChildTca>
                                <columns type="array">
                                    <uid_local type="array">
                                        <config type="array">
                                            <appearance type="array">
                                                <elementBrowserType>file</elementBrowserType>
                                                <elementBrowserAllowed>jpg,png,svg,jpeg,gif</elementBrowserAllowed>
                                            </appearance>
                                        </config>
                                    </uid_local>
                                </columns>
                                <types type="array">
                                    <numIndex index="2">
                                        <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                                    </numIndex>
                                </types>
                            </overrideChildTca>
                        </config>
                    </TCEforms>
                </settings.image>

我现在如何访问这些图像?
如果我调试它,我只会得到 INT 1"在前端.

How can i access this images now?
If I debug it, I just get INT "1" at the frontend.

我知道我需要一个 DataProcessor,但是把它放在哪里以及具体放什么?

I know I need a DataProcessor, but where to put it and what to put exactly?

我有一个 Typoscript Conf,我可以把处理器放在这里吗?:

I got a Typoscript Conf, can I put the Processor here?:

page.includeCSS.filedsheader = EXT:dsheader/Resources/Public/Css/dsheader.css
page.includeJSFooter.filedsheader = EXT:dsheader/Resources/Public/Js/dsheader.js

plugin.tx_dsheader {
    view {
        templateRootPath = {$plugin.tx_dsheader.view.templateRootPath}
        partialRootPath = {$plugin.tx_dsheader.view.partialRootPath}
        layoutRootPath = {$plugin.tx_dsheader.view.layoutRootPath}
    }
    persistence {
        storagePid = {$plugin.tx_dsheader.persistence.storagePid}
    }
    features {
        # uncomment the following line to enable the new Property Mapper.
        # rewrittenPropertyMapper = 1
    }
}

我的控制器:也许我在这里遗漏了什么?

My Controller: Maybe I'm missing something here?

<?php
namespace Alroma\Dsheader\Controller;
/**
 *
 * @category    Controller
 */
class ContentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
    
    /**
     * @var \TYPO3\CMS\Core\Resource\FileRepository
     * @TYPO3\CMS\Extbase\Annotation\Inject
     */
    protected $fileRepository;
    
    /**
     * @return void
     */
    public function dsheaderAction() {
        
        $data = $this->configurationManager->getContentObject()->data;
        $this->view->assign('data', $data);
    }

    
}

推荐答案

你说得对,你只需要添加一个数据处理器.您可以在 setup.ts 中执行此操作:...

You are right, you just needed to add a data processor. You can do this in setup.ts: ...

dataProcessing.20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.20 {
    if.isTrue.field = settings.image
    references {
        fieldName = settings.image
        table = tt_content
    }
    as = ImageNameHere
}

...这可能会作为数组返回,因此在流体中使用 foreach 将其保存为变量名:

...this will probably return as an array, so in fluid use a foreach to save it to a variable name:

    <f:for each="{ImageNameHere}" as="file" iteration="iterator">
      <f:variable name="fileurl"><f:uri.image image="{file}"/></f:variable>
    </f:for>

...然后你可以在 HTML 中引用它

...and then you can reference it in HTML

    <div style="background-image:url({fileurl});"></div>

这篇关于扩展中的 TYPO3 FAL 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆