Skip to content

Commit

Permalink
Fixed #2408
Browse files Browse the repository at this point in the history
  • Loading branch information
andris-sevcenko committed Jul 11, 2018
1 parent 70853ba commit b250b54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for Craft CMS 3.x

## Unreleased

### Changed
- Craft no longer relies on Imagick or GD to tell what image formats they support, when considering if it can manipulate an image. ([#2408](https://github.com/craftcms/cms/issues/2408))

## 3.0.15 - 2018-07-09

### Changed
Expand Down
31 changes: 8 additions & 23 deletions src/services/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class Images extends Component
// Properties
// =========================================================================

/**
* Image formats that can be manipulated.
*
* @var array
*/
public $supportedImageFormats = ['jpg', 'jpeg', 'gif', 'png'];

/**
* Image driver.
*
Expand Down Expand Up @@ -120,29 +127,7 @@ public function getVersion(): string
*/
public function getSupportedImageFormats(): array
{
if ($this->getIsImagick()) {
return array_map('strtolower', Imagick::queryFormats());
}

$output = [];
$map = [
IMG_JPG => ['jpg', 'jpeg'],
IMG_GIF => ['gif'],
IMG_PNG => ['png'],
];

// IMG_WEBP was added in PHP 7.0.10
if (defined('IMG_WEBP')) {
$map[IMG_WEBP] = ['webp'];
}

foreach ($map as $key => $extensions) {
if (imagetypes() & $key) {
$output = array_merge($output, $extensions);
}
}

return $output;
return $this->supportedImageFormats;
}

/**
Expand Down

0 comments on commit b250b54

Please sign in to comment.