function GDToolkit::extensionToImageType
Same name in other branches
- 9 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::extensionToImageType()
- 10 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::extensionToImageType()
- 11.x 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 446
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.