@@ -98,31 +98,24 @@ export default async function decorate(block) {
9898 // Add image or video if they exist.
9999 if ( pageHeaderData . visual ) {
100100 if ( pageHeaderData . visual ?. nodeName == "PICTURE" ) {
101- // Image
102- let pageHeaderVisual = pageHeaderData . visual ;
101+ // Image:
102+ const visualWrapper = document . createElement ( "div" ) ;
103+ visualWrapper . classList . add ( "page-header__image" , "grid-item" , "grid-item--50" ) ;
103104
104- // If there's a link, wrap the image in an anchor .
105+ // If there's a link, add it adjacent to image .
105106 if ( pageHeaderData . anchorNode ) {
106- const wrappingAnchor = document . createElement ( "a" ) ;
107- wrappingAnchor . setAttribute ( "href" , anchorHref ) ;
108-
109- // Give the link a proper accessible name.
110- wrappingAnchor . setAttribute ( "aria-label" , pageHeaderData . altText ? pageHeaderData . altText : pageHeaderData . title ) ;
111-
112- // Treat image as decorative. It is already described by the adjacent text.
113- const imgElement = pageHeaderVisual . querySelector ( 'img' ) ;
114- if ( imgElement ) {
115- imgElement . setAttribute ( "alt" , "" ) ;
116- }
117-
118- wrappingAnchor . append ( pageHeaderVisual ) ;
119- pageHeaderVisual = wrappingAnchor ;
107+ const imageAnchor = document . createElement ( "a" ) ;
108+ imageAnchor . setAttribute ( "href" , anchorHref ) ;
109+ // Allows clicking image but prevents repetitive link text from being read.
110+ imageAnchor . setAttribute ( "aria-hidden" , "true" ) ;
111+ imageAnchor . setAttribute ( "tabindex" , "-1" ) ;
112+ visualWrapper . append ( imageAnchor ) ;
120113 }
121-
122- pageHeaderVisual . classList . add ( "page-header__image" , "grid-item" , "grid-item--50" ) ;
123- pageHeader . append ( pageHeaderVisual ) ;
114+
115+ visualWrapper . append ( pageHeaderData . visual ) ;
116+ pageHeader . append ( visualWrapper ) ;
124117 } else {
125- // Video
118+ // Video:
126119 const embedCode = pageHeaderData . visual ?. innerText ?. trim ( ) ;
127120 if ( embedCode . startsWith ( "<iframe" ) ) {
128121 // Create a figure and populate it with the embed code.
0 commit comments