@@ -59,6 +59,7 @@ class CardDirective(SphinxDirective):
5959 "img-top" : directives .uri ,
6060 "img-bottom" : directives .uri ,
6161 "img-background" : directives .uri ,
62+ "img-alt" : directives .unchanged ,
6263 "link" : directives .uri ,
6364 "link-type" : make_choice (["url" , "any" , "ref" , "doc" ]),
6465 "link-alt" : directives .unchanged ,
@@ -96,13 +97,15 @@ def create_card(
9697 )
9798 inst .set_source_info (card )
9899
100+ img_alt = options .get ("img-alt" ) or ""
101+
99102 container = card
100103 if "img-background" in options :
101104 card .append (
102105 nodes .image (
103106 uri = options ["img-background" ],
104107 classes = ["sd-card-img" ],
105- alt = "background image" ,
108+ alt = img_alt ,
106109 )
107110 )
108111 overlay = create_component ("card-overlay" , ["sd-card-img-overlay" ])
@@ -114,7 +117,7 @@ def create_card(
114117 image_top = nodes .image (
115118 "" ,
116119 uri = options ["img-top" ],
117- alt = "card-img-top" ,
120+ alt = img_alt ,
118121 classes = ["sd-card-img-top" ] + options .get ("class-img-top" , []),
119122 )
120123 container .append (image_top )
@@ -156,7 +159,7 @@ def create_card(
156159 image_bottom = nodes .image (
157160 "" ,
158161 uri = options ["img-bottom" ],
159- alt = "card-img-bottom" ,
162+ alt = img_alt ,
160163 classes = ["sd-card-img-bottom" ] + options .get ("class-img-bottom" , []),
161164 )
162165 container .append (image_bottom )
0 commit comments