You are here

public function GDToolkitWebP::extensionToImageType in Picture 8

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.

Overrides GDToolkit::extensionToImageType

See also

image_type_to_extension()

File

src/Plugin/ImageToolkit/GDToolkitWebP.php, line 219
Contains \Drupal\system\Plugin\ImageToolkit\GDToolkit.

Class

GDToolkitWebP
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\picture\Plugin\ImageToolkit

Code

public function extensionToImageType($extension) {
  if ($extension === 'webp') {
    return GDToolkitWebP::IMAGETYPE_WEBP;
  }
  foreach ($this
    ->supportedTypes() as $type) {
    if (image_type_to_extension($type, FALSE) === $extension) {
      return $type;
    }
  }
  return IMAGETYPE_UNKNOWN;
}