Search the blog

When you enable Webp support on your ProcessWire site, it only creates WebP versions of variations. To create them of your original images as they are added (which I recommend to improve front-end performance), add the following hook to your admin.php page.

					
wire()->addHookAfter('InputfieldImage::fileAdded', function(\ProcessWire\HookEvent $event) {

    $image = $event->argumentsByName('pagefile');
	
	// Simply calling it will create the image; nothing needs returning
	$image->webp->url;
	 
});					
				
Tim Bennett is a web designer and developer. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.