function GDToolkit::extensionToImageType

Same name in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::extensionToImageType()
  2. 10 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::extensionToImageType()
  3. 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

image_type_to_extension()

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\ImageToolkit

Code

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.