protected function ImagemagickFormatMapper::resolveEnabledFormats in ImageMagick 8.2
Same name and namespace in other branches
- 8.3 src/ImagemagickFormatMapper.php \Drupal\imagemagick\ImagemagickFormatMapper::resolveEnabledFormats()
- 8 src/ImagemagickFormatMapper.php \Drupal\imagemagick\ImagemagickFormatMapper::resolveEnabledFormats()
Returns the enabled image formats, processing the config map.
Results are cached for subsequent access. Saving the config will invalidate the cache.
Return value
array An associative array with ImageMagick formats as keys and their MIME type as values.
2 calls to ImagemagickFormatMapper::resolveEnabledFormats()
- ImagemagickFormatMapper::getEnabledFormats in src/
ImagemagickFormatMapper.php - Gets the list of currently enabled image formats.
- ImagemagickFormatMapper::resolveEnabledExtensions in src/
ImagemagickFormatMapper.php - Returns the enabled image file extensions, processing the config map.
File
- src/
ImagemagickFormatMapper.php, line 179
Class
- ImagemagickFormatMapper
- Provides the ImageMagick format mapper.
Namespace
Drupal\imagemagickCode
protected function resolveEnabledFormats() {
if ($cache = $this->cache
->get("imagemagick:enabled_formats")) {
$enabled_image_formats = $cache->data;
}
else {
$config = $this->configFactory
->get('imagemagick.settings');
$image_formats = $config
->get('image_formats');
$enabled_image_formats = [];
foreach ($image_formats as $format => $data) {
if (!isset($data['enabled']) || isset($data['enabled']) && $data['enabled']) {
if (isset($data['mime_type'])) {
try {
(new MimeType($data['mime_type']))
->getExtensions();
$enabled_image_formats[$format] = $data['mime_type'];
} catch (MimeTypeMappingException $e) {
// Just continue.
}
}
}
}
ksort($enabled_image_formats);
$this->cache
->set("imagemagick:enabled_formats", $enabled_image_formats, Cache::PERMANENT, $config
->getCacheTags());
}
return $enabled_image_formats;
}