Configuration 

The extension works out of the box with sensible defaults. Images are automatically optimized when accessed via the /processed/ path.

SourceSetViewHelper 

The SourceSetViewHelper generates responsive <img> tags with srcset attributes.

Basic ViewHelper usage
{namespace nr=Netresearch\NrImageOptimize\ViewHelpers}

<nr:sourceSet path="{f:uri.image(image: image)}"
              width="1200"
              height="800"
              alt="{image.properties.alternative}"
              sizes="(max-width: 768px) 100vw, 50vw"
/>
Copied!

Parameters 

path

path
Type
string
Required

true

Public path to the source image (for example /fileadmin/foo.jpg), typically generated via f:uri.image().

width

width
Type
int|float
Default
0

Base width in pixels for the rendered <img>. 0 resolves automatically from the source file.

height

height
Type
int|float
Default
0

Base height in pixels. 0 preserves aspect ratio relative to width.

set

set
Type
array
Default
[]

Responsive set in the form {maxWidth: {width: int, height: int}}. Each entry becomes a <source media="(max-width: <maxWidth>px)"> tag.

alt

alt
Type
string
Default
empty string

Alternative text (accessibility). HTML-escaped.

title

title
Type
string
Default
empty string

Title attribute for the image. HTML-escaped.

class

class
Type
string
Default
empty string

CSS classes for the <img> tag; include lazyload to use JS lazy load.

attributes

attributes
Type
array
Default
[]

Extra HTML attributes merged into the rendered tag.

lazyload

lazyload
Type
boolean
Default
false

Add loading="lazy" (native lazy loading).

sizes

sizes
Type
string
Default
auto, (min-width: 992px) 991px, 100vw

Responsive sizes attribute for the generated <img> tag.

mode

mode
Type
string
Default
cover

Render mode. cover resizes images to fully cover the given dimensions. fit resizes images to fit within the given dimensions.

responsiveSrcset

responsiveSrcset
Type
boolean
Default
false

Enable width-based responsive srcset instead of density-based 2x srcset.

widthVariants

widthVariants
Type
string|array
Default
480, 576, 640, 768, 992, 1200, 1800

Width variants for responsive srcset (comma-separated string or array).

fetchpriority

fetchpriority
Type
string
Default
empty string

Native HTML fetchpriority attribute. Allowed values: high, low, auto. Omitted when empty.

Encoding quality 

The encoding quality is not configurable per ViewHelper call -- there is no quality argument. Generated URLs always carry the default quality of 75 (for example /processed/fileadmin/image.w1200h800m0q75.jpg), and variant requests that carry no q value are processed with the same default.

Source set configuration 

Define source sets per media breakpoint via the set attribute:

Source set with breakpoint-specific dimensions
<nr:sourceSet
    path="{f:uri.image(
        image: image,
        width: '960',
        height: '690',
        cropVariant: 'default'
    )}"
    set="{
        480:{width: 160, height: 90},
        800:{width: 400, height: 300}
    }"
/>
Copied!

Render modes 

cover
Default. Resizes images to fully cover the provided width and height.
fit
Resizes images so they fit within the provided width and height.
Using fit mode
<nr:sourceSet
    path="{f:uri.image(
        image: image,
        width: '960',
        height: '690',
        cropVariant: 'default'
    )}"
    width="960"
    height="690"
    mode="fit"
/>
Copied!

Lazy loading 

Both modes support lazy loading via the native loading="lazy" attribute. When using JS-based lazy loading (class="lazyload"), the data-srcset attribute is added automatically.

Backward compatibility 

By default responsiveSrcset is false, preserving the existing 2x density-based srcset behavior. All existing templates continue to work without modifications.

Additional trusted roots 

New in version 1.3.0

The additionalTrustedRoots extension configuration setting. TYPO3's var/ directory is now trusted automatically.

Some deployments need to serve variants of images that live under an absolute filesystem path that is neither the public webroot, a Local FAL storage's own base path, nor one of the hardcoded TYPO3-internal locations (var/, symlinked processed/uploads, or extension-published _assets/<hash> directories) -- for example a custom mount managed outside of FAL.

The additionalTrustedRoots extension configuration setting closes this gap on an explicit, per-instance, opt-in basis: a comma-separated list of absolute filesystem paths that are realpath-resolved and added to the allow-list directly.

config/system/additional.php
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['nr_image_optimize']['additionalTrustedRoots'] = '/mnt/custom-assets';
Copied!

The setting can also be edited via the backend: Admin Tools > Settings > Extension Configuration > nr_image_optimize.

WebP/AVIF output quality 

New in version 1.3.0

The qualityWebp and qualityAvif extension configuration settings.

The primary variant's quality is controlled per-request via the q<n> URL segment. The .webp and .avif sidecars previously reused that same numeric quality, but AVIF's quality scale is steeper than WebP's or JPEG's -- at matching numbers an AVIF file comes out larger than the WebP sidecar, defeating the point of serving AVIF at all.

Two extension configuration settings control sidecar quality independently of the primary variant:

qualityWebp (default 75)
Output quality for the generated WebP variant.
qualityAvif (default 60)
Output quality for the generated AVIF variant. The lower default keeps AVIF variants genuinely smaller than WebP while staying visually comparable.
config/system/additional.php
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['nr_image_optimize']['qualityWebp'] = 75;
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['nr_image_optimize']['qualityAvif'] = 60;
Copied!

The settings can also be edited via the backend: Admin Tools > Settings > Extension Configuration > nr_image_optimize.