Jump to content

Write additional files within hookWatermark


Later42

Recommended Posts

Hello all,

 

I'm trying to add webp support for my store. Now, I'd like to create the required images immediately after upload via the hookWatermark. For some reason, however, these fail to materialise: the jpgs show up perfectly, but no webp images can be found in the image directory.

 

This is the code that is called from this hook:

		$image = new Image($params['id_image']);
		$image->id_product = $params['id_product'];
		
		foreach ($this->imageTypes as $imageType) // loop over every image type
		{
			$imgBasename = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'-'.stripslashes($imageType['name']);
			$img = WebPSupport::getImageByType($imgBasename.'.jpg');

			if ($img !== false)
			{
				imagewebp($img, $imgBasename.'.webp');
				imagedestroy($img);
			} else
				return false;
		}

What am I doing wrong? I'd really appreciate any input on this.

Edited by Later42 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...