Skip to content

Commit

Permalink
Merge pull request PrestaShop#28711 from Progi1984/issue27706
Browse files Browse the repository at this point in the history
Fixed WebP Management in WebService
  • Loading branch information
matks authored Nov 18, 2022
2 parents 9c97f27 + b15a540 commit 1c89e73
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions classes/webservice/WebserviceSpecificManagementImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ class WebserviceSpecificManagementImagesCore implements WebserviceSpecificManage
/**
* @var array The list of supported mime types
*/
protected $acceptedImgMimeTypes = ['image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'];
protected $acceptedImgMimeTypes = [
'image/gif',
'image/jpg',
'image/jpeg',
'image/pjpeg',
'image/png',
'image/webp',
'image/x-png',
];

/**
* @var string The product image declination id
Expand Down Expand Up @@ -148,6 +156,10 @@ public function getContent()
'function' => 'imagecreatefromgif',
'Content-Type' => 'image/gif',
],
'webp' => [
'function' => 'imagecreatefromwebp',
'Content-Type' => 'image/webp',
],
];
if (array_key_exists($this->imgExtension, $types)) {
$imageResource = @$types[$this->imgExtension]['function']($this->imgToDisplay);
Expand Down Expand Up @@ -904,18 +916,18 @@ protected function writeImageOnDisk($base_path, $new_path, $dest_width = null, $
$dest_height = $source_height;
}
switch ($type) {
case 1:
case IMAGETYPE_GIF:
$source_image = imagecreatefromgif($base_path);

break;
case 3:
case IMAGETYPE_PNG:
$source_image = imagecreatefrompng($base_path);

break;
case 2:
case IMAGETYPE_WEBP:
$source_image = imagecreatefromwebp($base_path);
break;
case IMAGETYPE_JPEG:
default:
$source_image = imagecreatefromjpeg($base_path);

break;
}

Expand Down

0 comments on commit 1c89e73

Please sign in to comment.