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('cockpit.assets.save', function (&$assets) {
foreach ($assets as $asset) {
$dir = $asset['path'];
$webPDir = strtok($dir, '.') . '.webp';
$img = imagecreatefrompng( COCKPIT_DIR . "/storage/uploads" . $dir);
imagepalettetotruecolor($img);
imagealphablending($img, true);
imagesavealpha($img, true);
imagewebp($img, COCKPIT_DIR . "/storage/uploads" . $webPDir, 100);
imagedestroy($img);
}
}
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?