public function GDToolkit::extensionToImageType in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::extensionToImageType()
Returns the IMAGETYPE_xxx constant for the given extension.
This is the reverse of the image_type_to_extension() function.
Parameters
string $extension: The extension to get the IMAGETYPE_xxx constant for.
Return value
int The IMAGETYPE_xxx constant for the given extension, or IMAGETYPE_UNKNOWN for unsupported extensions.
See also
File
- core/
modules/ system/ src/ Plugin/ ImageToolkit/ GDToolkit.php, line 450
Class
- GDToolkit
- Defines the GD2 toolkit for image manipulation within Drupal.
Namespace
Drupal\system\Plugin\ImageToolkitCode
public function extensionToImageType($extension) {
if (in_array($extension, [
'jpe',
'jpg',
])) {
$extension = 'jpeg';
}
foreach ($this
->supportedTypes() as $type) {
if (image_type_to_extension($type, FALSE) === $extension) {
return $type;
}
}
return IMAGETYPE_UNKNOWN;
}