svenjuergens/cs-webp

Convert images to webp

Installs: 3 247

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 4

Type:typo3-cms-extension

5.0.0 2024-01-23 11:11 UTC

This package is auto-updated.

Last update: 2024-04-23 11:38:06 UTC


README

What does it do?

The extension copies and converts all png and jpg images in the fileadmin/processed folder to the webp format. Browser which could read webp images load the webp images instead of the jpg or png files. The webp images are generated when new processed images in jpg or png format are added in the processed folder.

Important

Every jpg or png image is stored as webp file a second time in the folder (bigger storage size).

Installation

Simply install the extension with Extension Manager or Composer composer require svenjuergens/cs-webp Clear the processed images in the install-tool and reload the Backend. Add the code in the head of your root .htaccess file. This .htaccess Code rewrites the jpg and png images to the webp files if webp is readable in the browser. Change the level of quality if needed in the extension configuration in extension manager (default 65)

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_ACCEPT} image/webp
        RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
        RewriteRule ^(fileadmin/_processed_.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
    </IfModule>

    <IfModule mod_headers.c>
        Header append Vary Accept env=REDIRECT_accept
    </IfModule>

    AddType image/webp .webp