function ResponsiveImageBuilder::getMimeType
Determines the MIME type of an image.
Parameters
string $image_style_name: The image style that will be applied to the image.
string $extension: The original extension of the image (without the leading dot).
Return value
string|null The MIME type of the image after the image style is applied, or NULL if not found.
1 call to ResponsiveImageBuilder::getMimeType()
- ResponsiveImageBuilder::buildSourceAttributes in core/
modules/ responsive_image/ src/ ResponsiveImageBuilder.php - Helper function for template_preprocess_responsive_image().
File
-
core/
modules/ responsive_image/ src/ ResponsiveImageBuilder.php, line 302
Class
- ResponsiveImageBuilder
- Provides methods related to building responsive image source attributes.
Namespace
Drupal\responsive_imageCode
public function getMimeType(string $image_style_name, string $extension) : ?string {
$extension = match ($image_style_name) { ResponsiveImageStyleInterface::EMPTY_IMAGE => 'gif',
ResponsiveImageStyleInterface::ORIGINAL_IMAGE => $extension,
default => $this->entityTypeManager
->getStorage('image_style')
->load($image_style_name)
->getDerivativeExtension($extension),
};
return $this->mimeTypeMap
->getMimeTypeForExtension($extension);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.