function responsive_image_get_mime_type
Same name and namespace in other branches
- 9 core/modules/responsive_image/responsive_image.module \responsive_image_get_mime_type()
- 8.9.x core/modules/responsive_image/responsive_image.module \responsive_image_get_mime_type()
- 10 core/modules/responsive_image/responsive_image.module \responsive_image_get_mime_type()
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 responsive_image_get_mime_type()
- _responsive_image_build_source_attributes in core/
modules/ responsive_image/ responsive_image.module - Helper function for template_preprocess_responsive_image().
File
-
core/
modules/ responsive_image/ responsive_image.module, line 443
Code
function responsive_image_get_mime_type($image_style_name, $extension) {
$extension = match ($image_style_name) { ResponsiveImageStyleInterface::EMPTY_IMAGE => 'gif',
ResponsiveImageStyleInterface::ORIGINAL_IMAGE => $extension,
default => ImageStyle::load($image_style_name)->getDerivativeExtension($extension),
};
return \Drupal::service(MimeTypeMapInterface::class)->getMimeTypeForExtension($extension);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.