- Issue created by @mpotter
- πΊπΈUnited States mglaman WI, USA
We have an internal ticket for this, I linked them up on our side. We will be picking it up this week or next.
We needed a custom responsive image formatter. That was added before alt text was finalized. So we're missing setting the alt text in our field formatter.
- πΊπΈUnited States mpotter
Thanks for the quick answer. Look forward to seeing it and will be happy to test it. It's the remaining issue preventing us from using the DAM on our web site.
- πΊπΈUnited States mpotter
Oh, hmm, I think it's actually working already! I had missed a step and had not set up the display view modes for the DAM-Image media entity itself. In that display mode, for the "Asset Reference" in the Format option, instead of using "Embed Core" I see an option for "Acquia DAM Responsive Image". When I select that and point it to the correct image style, now it all works.
- πΊπΈUnited States mglaman WI, USA
Oh, really? In my notes I took, I thought we needed some extra work in our render array.
We have:
$elements[] = [ '#theme' => 'responsive_image', '#responsive_image_style_id' => $responsive_image_style ? $responsive_image_style->id() : '', '#uri' => $uri, '#cache' => [ 'tags' => $cache_tags, ], '#width' => $image_attributes['width'], '#height' => $image_attributes['height'], ];
We're missing some tricks the normal field formatter has in
template_preprocess_responsive_image_formatter
$variables['responsive_image'] = [ '#type' => 'responsive_image', '#responsive_image_style_id' => $variables['responsive_image_style_id'], ]; $attributes['alt'] = $item->alt; $variables['responsive_image']['#attributes'] = $attributes;
So I assumed we needed to fetch the alt text ourselves and properly set it. I haven't yet manually verified, but this in my sprint which kicked off today so I'll be double checking.
- πΊπΈUnited States mpotter
Correct, the Alt Text is definitely not set. We are setting that in a preprocess from the image name. So still get that added when you can. But without the alt text it is still rendering a responsive image that works.
- Status changed to Needs review
over 1 year ago 3:54pm 26 May 2023 - last update
over 1 year ago 199 pass - πΊπΈUnited States mglaman WI, USA
Here's a patch. @mpotter does this match to what you've done?
- πΊπΈUnited States mpotter
That patch seems reasonable to pull the Alt text from the mapped field from the DAM. In our case we didn't have any Alt Text field in the DAM itself and just created a preprocess function to use the Filename (without extension) as the Alt text for now.
- Status changed to Fixed
over 1 year ago 4:43pm 31 May 2023 - πΊπΈUnited States mglaman WI, USA
This was committed with https://git.drupalcode.org/project/acquia_dam/-/commit/8b005ec918fd1f7e1... and will be part of the next release!
Thanks for helping debug @mpotter
Automatically closed - issue fixed for 2 weeks with no activity.