plan2net / webp

Create a WebP copy for images (TYPO3 CMS)
GNU General Public License v3.0
60 stars 34 forks source link

Webp images are not served #44

Closed notacoder-ui closed 2 years ago

notacoder-ui commented 3 years ago

Hi,

I used the extension version 2.2.2 in my typo3 version 9.5.19.

I followed the steps as described in the Readme file.

I selected external converter option in extension configuration and passed parameter as image/jpeg::/usr/bin/cwebp -jpeg_like %s -o %s|image/png::/usr/bin/cwebp -lossless %s -o %s

and selected convert_all options too.

But, still webp images are served in my latest chrome browser.

Please help me where I am going wrong?

image (1) image

wazum commented 3 years ago

@notacoder-ui which webserver are you using and what's your webserver configuration? Did you check the TYPO3 log file (see documentation for troubleshooting advice)?

discotizer commented 3 years ago

@notacoder-ui did you modify the htaccess file so webp images are served instead of jpeg? have you checked if webp images are being created in the proccessed folder?

plojewski commented 3 years ago

@notacoder-ui I had the same problem. When you install via composer, the database table hasn't create and webp is not being generated. You have to run Upgrade wizard to create table: tx_webp_failed

wazum commented 3 years ago

@plojewski that's standard behaviour ;-) If you don't use something like

typo3cms extension:setupactive

with the help of TYPO3 console extension, you won't get any new tables/fields when installing extensions with composer.

sunixzs commented 3 years ago

Hi. I had the same or a similar problem: in local development all works fine but in staging on a Strato-Server the redirect won't work. Extension, table in database, image (webp) generation worked but no image/webp result in browser inspector.

I solved it by testing hours around with the .htaccess stuff and resulted with this one in the beginning of the .htaccess file. (Changed the one line from the docs which checks if the file exists.)

#####
# Extension "webp": redirect to webp version of images
# (enable on production)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP_ACCEPT} image/webp

    # The second line works with STRATO:
    # RewriteCond %{DOCUMENT_ROOT}/$1.$3.webp -f
    RewriteCond %{REQUEST_FILENAME}\.webp -f

    RewriteRule ^((fileadmin|other-storage)/.+)\.(png|jpg|jpeg)$ $1.$3.webp [L]
</IfModule>

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

# type will be set in default typo3 stuff below
# AddType image/webp .webp
#####

Maybe this helps the one or other.

xerc commented 2 years ago
  RewriteCond %{HTTP_ACCEPT} image/webp
  RewriteCond %{REQUEST_FILENAME}\.webp -f
  RewriteRule ^ %{REQUEST_FILENAME}.webp [L]

ref. https://github.com/plan2net/webp/pull/54/commits/3f4043f0a87f01d1cb34d0a5c22dd59ae395947d#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R132-R134

xerc commented 2 years ago

resulted with this one in the beginning of the .htaccess file

this is NOT recommended ; insert @ https://github.com/TYPO3/typo3/blob/f43979e74409500b731a98b39f978379669ed2e9/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess#L301 or https://github.com/TYPO3/typo3/blob/f43979e74409500b731a98b39f978379669ed2e9/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess#L322