Allow image effects to change the MIME type + extension, add a "convert" image effect

Created on 1 September 2014, almost 10 years ago
Updated 3 January 2024, 6 months ago

Follow-up to #2262863: Add srcset to template_preprocess_image

Problem/Motivation

  • The new picture html tag allows to define alternatives based on mime type (image format) using the type attribute. To render this attribute, we need to be able to determine the mime type of a derivative without generating it.
  • To be able to generate derivatives in multiple output formats, we need an image effect that can change the format an image is saved in.

Proposed resolution

  • Add ImageEffectInterface::getDerivativeMimeType(&$mime_type)
  • Add ImageEffectInterface::getDerivativeExtension(&$extension)
  • Now that ImageStyle supports changing the MIME type & extension, add a "convert" ImageEffect

User interface changes

None

API changes

  • Adds ImageEffectInterface::getDerivativeMimeType(&$mime_type)
  • Adds ImageStyleInterface::getDerivativeMimeType(&$mime_type)
  • Adds ImageEffectInterface::getDerivativeExtension(&$extension)
  • Adds ImageStyleInterface::getDerivativeExtension(&$extension)
  • Adds ImageInterface::convert($format)
  • (Adds \Drupal\image\Plugin\ImageEffect\ConvertImageEffect)
  • (Adds \Drupal\system\Plugin\ImageToolkit\Operation\gd\Convert)
📌 Task
Status

Fixed

Version

8.0 ⚰️

Component
Image system 

Last updated about 4 hours ago

Created by

🇧🇪Belgium attiks

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024