Conversion images to webp

Hi, what is the best way to conversion all stored images to web format?

I did addon where I create listener method in bootstrap.php

$app->on('', function (&$assets) {

    foreach ($assets as $asset) {
        $dir = $asset['path'];
        $webPDir = strtok($dir, '.') . '.webp';

        $img = imagecreatefrompng( COCKPIT_DIR . "/storage/uploads" . $dir);
        imagealphablending($img, true);
        imagesavealpha($img, true);
        imagewebp($img, COCKPIT_DIR . "/storage/uploads" . $webPDir, 100);

This work that way if I upload any file (png at this moment) it really create a webp file and store in the same folder as my original file. But problem is that I cant see this in my assets list http://localhost:8080/assetsmanager.

I can see there only my original file at this list. What can I do more to see this converted image in my assets list?

1 Like

I don’t know is it right way to do it. Probably not :see_no_evil:.
But I have modified in the file:


In selectImage function I have modified pattern and its working

{ typefilter:'image', pattern: '*.jpg|*.jpeg|*.png|*.gif|*.svg|*.webp' }

Is your addon publicly available?