Image rendering
FileUtility
The file rendering in EXT:
is handled by File
which renders the following JSON for each file:
"publicUrl": "https://www.example.org/fileadmin/_processed_/6/c/csm_my-image_51125112.jpg"
"properties": {
"mimeType": "image/jpeg",
"type": "image",
"filename": "csm_my-image_51125112.jpg",
"link": null,
"linkData": null,
"originalUrl": "https://www.example.org/fileadmin/my-image.jpg",
"uidLocal": "123",
"fileReferenceUid": "234",
"size": "50 KB",
"dimensions": {
"width": "300",
"height": "100",
},
"cropDimensions": {
"width": "300",
"height": "100",
},
"crop": { ... },
"autoplay": null,
"extension": null
}
The file rendering can be simplified via legacy
= 0 processing configuration flag
lib.meta {
fields {
ogImage = TEXT
ogImage {
dataProcessing {
10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
10 {
as = media
references.fieldName = og_image
processingConfiguration {
legacyReturn = 0
}
}
}
}
}
}
Will output:
"url": "https://www.example.org/fileadmin/_processed_/6/c/csm_my-image_51125112.jpg"
"mimeType": "image/jpeg",
"type": "image",
"filename": "csm_my-image_51125112.jpg",
"originalUrl": "https://www.example.org/fileadmin/my-image.jpg",
"link": null,
"uidLocal": "123",
"fileReferenceUid": "234",
"size": "50 KB",
"dimensions": {
"width": "300",
"height": "100",
},
"cropDimensions": {
"width": "300",
"height": "100",
},
"crop": { ... },
"autoplay": null,
"extension": null
EnrichFileDataEvent
File
is emitting the event Enrich
for manipulating the properties
array.
To add a listener add this to your Configuration/
:
My\Extension\EventListener\TweakFileData:
tags:
- name: event.listener
identifier: 'tweak-file-data'
event: FriendsOfTYPO3\Headless\Event\EnrichFileDataEvent
FilesProcessor
headless
provides its own Files
to render files.
Here's an example of how the og_
of a page is being rendered via TypoScript:
lib.meta {
fields {
ogImage = TEXT
ogImage {
dataProcessing {
10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
10 {
as = media
references.fieldName = og_image
processingConfiguration {
returnFlattenObject = 1
}
}
}
}
}
}
Configuration
The rendering configuration can be set via the property processing
and provides the following sub-properties:
legacy
(0|1): Allows to control new simplified output or old system (old system by default)Return link
(0|1): Allows to define if file object should return only url of defined link or whole LinkResult objectResult cache
(0|1): Allows to enable cacheBusting urls for processed filesBusting conditional
(0|1): Allows conditionally autogenerate files with defined variants if set (if not all variants are returned)Crop Variant process
(0|1): Enabled optional processing pdf files as image (default off)Pdf As Image process
(0|1): Enabled optional processing svg files (default off)Svg properties.
(0|1): Allows filter file properties by type (i.e. do not return video properties on images)by Type properties.
(coma separated list of fields): Default fields for when enabled optiondefault Fields By Type properties.
by Type properties.
(coma separated list of fields): Default fields for image type when enabled optiondefault Image Fields properties.
by Type properties.
(coma separated list of fields): Default fields for video type when enabled optiondefault Video Fields properties.
by Type properties.
(string, comma separated): Configure what file properties to returninclude Only properties.
(0|1): Flatten nested properties (dimensions array) to use withflatten properties.
include Only return
: without that flag an array of (multiple) images is rendered. Set this if you're only rendering 1 image and want to reduce nesting.Flatten Object delay
: can be used to skip processing of images (and have them simply collected with theProcessing Files
), in order to have them processed by the next processor in line (which is generallyProcessor Gallery
).Processor file
: can be used to convert the images to any desired format, e.g.Extension webp
.autogenerate
: `retina2x`: set this to render an additional image URI in high quality (200%).lqip
: set this to render an additional image URI with low quality (10%). * also custom defined size & file formats see example below
10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
10 {
...
processingConfiguration {
delayProcessing = 1
}
}
20 = FriendsOfTYPO3\Headless\DataProcessing\GalleryProcessor
20 {
...
autogenerate {
retina2x = 1
customFileWebp {
fileExtension = webp
factor = 1.0
}
customTinyJpg {
fileExtension = jpg
factor = 0.2
}
}
}
10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
10 {
...
processingConfiguration {
# (1 by default, return new format of file object)
legacyReturn = 0
# Return whole LinkResult object instead simple url
linkResult = 1
# check if we need to conditionally check if we should generate crop variants
conditionalCropVariant = 1
# Generate cacheBusting urls for images and video files
cacheBusting = 1
properties {
# return props by mimeType
byType = 1
# return only properties defined below
includeOnly = alternative,width,height
# you can also alias fields
# includeOnly = alternative as alt,width,height
# with includeOnly you can use option `flatten` to flatten dimensions array
flatten = 1
}
}
}
GalleryProcessor
Configuration
The rendering configuration can be set directly. No processing
property available!
max
: set to the core constantGallery Width {$styles.
content. textmedia. max W} max
: set to the core constantGallery Width In Text {$styles.
content. textmedia. max WIn Text} column
: set to the core constantSpacing {$styles.
content. textmedia. column Spacing} border
: set to the core constantWidth {$styles.
content. textmedia. border Width} border
: set to the core constantPadding {$styles.
content. textmedia. border Padding} autogenerate
`retina2x`lqip