Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Last active March 2, 2023 16:57
Show Gist options
  • Select an option

  • Save kitzberger/ba63a05d978729e3a5ac51c051aff917 to your computer and use it in GitHub Desktop.

Select an option

Save kitzberger/ba63a05d978729e3a5ac51c051aff917 to your computer and use it in GitHub Desktop.
TYPO3 and webp

Make sure PHP GD is compiled with support for webp:

$ php -i | grep -i webp
WebP Support => enabled
<?php
echo "webp support: " . (function_exists('imagewebp') && defined('IMG_WEBP') && (imagetypes() & IMG_WEBP) === IMG_WEBP ? 'yes' : 'no');

If not, see Dockerfile!

Make sure TYPO3 allows webp

$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] has to contain "webp".

Trouble shooting: images still don't convert after enabling webp.

TYPO3 saves any previously failed attempts to convert images to webp, so after enabling support you might wanna delete those failed attempts.

DELETE FROM sys_file_processedfile WHERE name IS NULL;

or go to the BE module "maintenance" and "Remove Temporary Assets".

RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
RUN apt-get install -y \
graphicsmagick \
webp
<!-- fileExtension attribute only since TYPO3 10.4 !-->
<f:uri.image src="..." fileExtension="webp" />
<!--
if you don't wanna specify the `fileExtension` parameter in all Fluid templates and
you're using `*.webp` files from the start keep in mind that TYPO3 changes to file format
when resizing images in AbstractGraphicalTask.php
see https://github.com/TYPO3-CMS/core/blob/main/Classes/Resource/Processing/AbstractGraphicalTask.php
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment