-->

How can I extract metadata properties from images

2019-09-03 21:03发布

问题:

Situation

sysext:filemetadata is activated; images (fal references) are deposited within page resources (pages.media).

2 options are currently known to me in conjunction to TYPO3 pages:

  1. Using a custom FAL viewhelper
  2. Using TypoScript (which is often illegible and not easy to maintain)

Question

What's actually (TYPO3 7.x and 8.x) a common/core-only solution to render such images within fluid with additional properties (metadata) like creator, copyright and so on?

回答1:

I would go for next approach:

typoscript

page.10 = FLUIDTEMPLATE
page.10 {
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        10 {
            references.fieldName = media
        }
    }
    ...
}

fluid

<f:for each="{files}" as="file">
    <div class="media">
        <figure>
            <f:media file="{file}" />
            <figcaption>
                {file.description}<br />
                author: {file.properties.creator}<br />
                copyright: {file.properties.copyright}
            </figcaption>
        </figure>
    </div>
</f:for>

...

To find all possible sys_file_reference and sys_file_metadata properties just add <f:debug>{file.properties}</f:debug> inside the <f:for ...</f:for>.