Responsive Images 

Extension key

responsive_images

Package name

codemonkey1988/responsive-images

Version

main

Language

en

Author

Tim Schreiner

License

This document is published under the Creative Commons BY 4.0 license.

Rendered

Wed, 06 May 2026 19:47:22 +0000

Extension for TYPO3 that adds the option to define centralized configurations for picture tags and render them using Fluid ViewHelpers. Configurations are defined using TypoScript.

About this extension 

This extension is based on the fact, that the integrator forces image sizes that the content editor may not change. An integrator can specify image configurations that are used in Fluid templates.

Upgrading from v2 

Installation 

This extension can be installed by using composer:

composer require codemonkey1988/responsive-images
Copied!

Continue with Configuration.

How to use 

To make this extension working, it needs rendering variants. These rendering variants are configured using TypoScript. Default configurations are provides by this extension. See Configuration how to use these.

When variants are provided, they needs to be rendered in frontend. The Frontend Rendering for examples.

Configuration 

Extension Configuration 

This extension does not require any TypoScript to be included. But this extension provides some example configuration that can be used for image rendering:

  • Responsive images default configuration (optional)
  • Responsive images bootstrap configuration (optional)

Only one of them should be included. These configurations provide the following variant keys:

Continue this Frontend Rendering after configuration is finished.

Default configuration 

This configuration is loaded by default when including the default extension TypoScript.

Variant key Size: smartphone Size: tablet Size: desktop
default 320px 1x, 640px 2x 1024px 1x, 2024px 2x 1920px 1x
half 320px 1x, 640px 2x 512px 1x, 1024px 2x 960px 1x
third 320px 1x, 640px 2x 341px 1x, 682px 2x 640px 1x
quarter 320px 1x, 640px 2x 256px 1x, 512px 2x 480px 1x
two-thirds 320px 1x, 640px 2x 682px 1x, 1364px 2x 1280px 1x
three-quarters 320px 1x, 640px 2x 768px 1x, 1536px 2x 1440px 1x

Bootstrap configuration 

This configuration can be loaded by adding the static TypoScript file Responsive images bootstrap configuration (optional).

Variant key Size: extraSmall Size: small Size: medium Size: large
default 400px 1x, 800px 2x 750px 1x, 1500px 2x 970px 1x, 1940px 2x 1170px 1x
col-12 400px 1x, 800px 2x 750px 1x, 1500px 2x 970px 1x, 1940px 2x 1170px 1x
col-11 400px 1x, 800px 2x 687px 1x, 1375px 2x 889px 1x, 1778px 2x 1072px 1x
col-10 400px 1x, 800px 2x 625px 1x, 1250px 2x 808px 1x, 1616px 2x 975px 1x
col-9 400px 1x, 800px 2x 562px 1x, 1125px 2x 727px 1x, 1455px 2x 877px 1x
col-8 400px 1x, 800px 2x 500px 1x, 1000px 2x 646px 1x, 1293px 2x 780px 1x
col-7 400px 1x, 800px 2x 437px 1x, 875px 2x 565px 1x, 1131px 2x 682px 1x
col-6 400px 1x, 800px 2x 375px 1x, 750px 2x 485px 1x, 970px 2x 585px 1x
col-5 400px 1x, 800px 2x 312px 1x, 625px 2x 404px 1x, 808px 2x 487px 1x
col-4 400px 1x, 800px 2x 250px 1x, 500px 2x 323px 1x, 646px 2x 390px 1x
col-3 400px 1x, 800px 2x 187px 1x, 375px 2x 242px 1x, 485px 2x 292px 1x
col-2 400px 1x, 800px 2x 125px 1x, 250px 2x 161px 1x, 323px 2x 195px 1x
col-1 400px 1x, 800px 2x 62px 1x, 125px 2x 80px 1x, 161px 2x 97px 1x

Frontend Rendering 

After variants are provided using TypoScript, the frontend rendering needs to be configured.

This extension provides a partial, that can be used for rendering image as picture tags.

How are variants chosen 

Configured variants can be provided by using the extensions ViewHelpers. When no variant is given, the extension tries to get the current variant from the TYPO3 register stack. It is looking for the key IMAGE_VARIANT_KEY. When it is defined, its value is used as a variant key. When no valid key is found, the extension will use the key default.

Example rendering 

The extension provides a partial that can be used for frontend rendering.

First, the extensions partial path needs to be added for rendering. For fluid_tyled_content this can be done like this

lib.contentElement.partialRootPaths.1663513618 = EXT:responsive_images/Resources/Private/Partials
Copied!

After this path is added, the partial can be used in Fluid:

<f:render partial="PictureTag" arguments="{
    image: files.0,
    imageMaxWidth: 1920,
    imgClass: 'image-1',
    imageDefaultCropVariant: 'desktop',
    cropVariants: {
        mobile: '(max-width: 700px)',
        desktop: '(min-width: 701px)'
    }
}" />
Copied!

See the partials code for an explanation what variable can be provides.

Using the ViewHelpers 

This extension provides some ViewHelpers:

IfAnimatedGifViewHelper 

This ViewHelper is a conditional ViewHelper that expects an image object. The ViewHelper will evaluate if this image is an animated gif.

The ViewHelper can be used to prohibit processing of animated gifs in order to keep their animations.

ImageViewHelper 

This ViewHelper extends the default Fluid ImageViewHelper. It uses the currently active variant or a specific variant key can be provided.

LoadRegisterViewHelper 

This ViewHelper can be used to set the currently used variant for rendering images. Every Fluid code (including partials, sections and als TypoScript libs) that renders an image will use the given key (if key is not overwrite by ViewHelper argument)

SourceViewHelper 

This ViewHelper renders a source tag for usage in a picture tag. The arguments cropVariantKey and media can be provided to archive different image cropping for different image sizes.

There is an option to specify the target extension for the given file. This may come in handy when providing webp images for the users.

Configuration Reference 

Variant Properties

croppingVariantKey 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.croppingVariantKey

| Data type: string |

The TYPO3 cropping variant key, that should be used by default.

providedImageSizes 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes

| Data type: array of image rendering options |

Add multiple image rendering configurations. This options is used to generate the available images provided in the srcset attribute.

providedImageSizes.<key>.width 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.width

Data type: string

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#width>

providedImageSizes.<key>.height 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.height

Data type: string

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#height>

providedImageSizes.<key>.maxWidth 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.maxWidth

Data type: int

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#maxw>

providedImageSizes.<key>.maxHeight 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.maxHeight

Data type: int

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#maxh>

providedImageSizes.<key>.minWidth 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.minWidth

Data type: int

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#minw>

providedImageSizes.<key>.minHeight 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.providedImageSizes.<key>.minHeight

Data type: int

See TYPO3 ImgResource <https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/Functions/Imgresource.html#minh>

Example:

providedImageSizes {
   10 {
      width = 500c
      height = 300c
   }
   20 {
      maxWidth = 900
   }
}
Copied!

sizes 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.sizes

| Data type: array of image sizes |

Add multiple sizes configurations. This options is used to generate the available images provided in the sizes attribute.

sizes.<key>.viewportMediaCondition 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.sizes.<key>.viewportMediaCondition

Data type: string (optional)

The condition at which for the assumedImageWidth. When none is given, the browsers assumes the assumedImageWidth as default when no other matches.

sizes.<key>.assumedImageWidth 

plugin.tx_responsiveimages.settings.variants.<VariantKey>.sizes.<key>.assumedImageWidth

Data type: string

The image width that is assumed when the viewportMediaCondition matches.

Example:

sizes {
   10 {
      viewportMediaCondition = (min-width: 971px)
      assumedImageWidth = 1170px
    }
    20 {
      viewportMediaCondition = (min-width: 751px)
      assumedImageWidth = 970px
    }
    30 {
      viewportMediaCondition = (min-width: 421px)
      assumedImageWidth = 750px
    }
    40 {
      # Last element is the default element and does not need a viewportMediaCondition
      assumedImageWidth = 420px
    }
}
Copied!

Upgrade from v2 to v3 

Version 3 of this extension is fully rewritten and follows a more modern way of rendering responsive images. Version 2 and 3 are not compatible with each other.

I'm sorry to say, that the v2 configuration will no longer work and where is not automated way to update the configuration.

Please have a look at how this extension works in Configuration and Frontend Rendering.

What should be done 

  1. Provide a new TypoScript configuration using variants
  2. Replace all f:media calls with the new Frontend Rendering
  3. Make sure to remove unnecessary TypoScript to keep your installation clean

Changelog 

4.1.3 

  • BUGFIX: Improve avoiding duplicate image uri in srcset attribute

4.1.2 

  • BUGFIX: Avoid duplicate image uri in srcset attribute

4.1.1 

  • TASK: Avoid using CompileWithRenderStatic in LoadRegisterViewHelper
  • TASK: Add PHP 8.4 to testing suite

4.1.0 

  • FEATURE: Add SiteSets for presets
  • FEATURE: Allow forcing type attribute in SourceViewHelper
  • TASK: Do not call deprecated ViewHelper methods in TYPO3 v13
  • BUGFIX: Avoid implicit nullable parameter declaration

4.0.0 

  • !!!TASK: Drop support for TYPO3 v10 and v11
  • TASK: Add support for TYPO3 v13

No migrations necessary.

3.1.3 

  • BUGFIX: Fixes an issue with symfony/dependency-injection v7

3.1.2 

  • TASK: Add compatibility for TYPO3 12.4

3.1.1 

  • TASK: Add compatibility for TYPO3 12.2

3.1.0 

  • FEATURE: Add compatibility for TYPO3 12.0
  • FEATURE: Allow setting the target file extension in SourceViewHelper
  • TASK: Add info about specifying the file extension in SourceViewHelper
  • TASK: Add changelog to documentation

3.0.1 

  • TASK: Add loading="lazy" attribute to PictureTag Partial
  • BUGFIX: Add documentation link to readme
  • BUGFIX: Exclude .ddev folder in composer package

3.0.0 

The extension was completely rewritten from scratch and the rendering of the frontend was updated. This extension now uses the attributes srcset and sizes on image and source tags to provide responsive images.

List of important changes

  • Drops TYPO3 v8 and v9 compatibility
  • Drops quality and greyscale options for image rendering
  • Drop processing and enabled TypoScript settings
  • Adds TYPO3 v11 compatibility
  • Drop support for v2 configuration - use variants for v3
  • Improved documentation

Please have a look at Upgrade from v2 to v3 for further instructions.