Problem/Motivation
image-formatter.html.twig template files in core only allow href attributes on links. This also seems to be a problem for the same file in Classy, responsive_image and Stable.
Proposed resolution
The template_preprocess_image_formatter function already accepts a \Drupal\Core\Url object which can have attributes set using on the object for rendering. As such, the template_preprocess_image_formatter would only need to be updated to add the attributes to the variable array passed to the twig theme files. The twig theme files would need to be updated to support rendering attributes on the links however.
Remaining tasks
TBD
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #12
catchIt's not clear what the use-case is. If you need to do something custom in the template, you can override it. If you're trying to do something in preprocess and think the template should support it, please post example code. Moving to 'support request' and needs more info.
Comment #13
Eric115 CreditAttribution: Eric115 at PreviousNext commentedThanks @catch, I think the use case here was that there wasn't a way to add classes to the img element without overriding the template, but I can't remember for sure.
I think it's fine to close this.