responsive_image_build_source_attributes() calls Drupal::service('file.mime_type.guesser.extension')->guess() over and over for all images in an srcset, while the actual file extensions will most likely be the same.

Maybe the _responsive_image_image_style_url() should do some sort of static caching ?

Comments

attiks’s picture

Extension can be different for each derivative but static caching for each combo of source and image style might be a speed improvement.

yched’s picture

well, we still need to call the image style to give us the resulting extension, but we can statically cache the [extension => mime type] resolution ?

attiks’s picture

True

mondrake’s picture

Wouldn't it be better to get this #2311679: Separate MIME type mapping from ExtensionMimeTypeGuesser in first, and then (if needed) do the static caching in the new file.mime_type.mapper service rather than here?

See also comment #39 in that issue.

yched’s picture

Status: Active » Closed (duplicate)

@mondrake: indeed, would be a much nicer cleanup.

Closing as a dupe then.