Skip to content

Commit

Permalink
Alt text
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Jul 3, 2020
1 parent 7e02942 commit 85d1752
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/TokamakDOM/Views/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ struct _HTMLImage: View {
public var body: some View {
let lookup = proxy.isSystem ? systemImages : images
if let src = lookup[proxy.imageName] {
return AnyView(HTML("img", ["src": src, "style": "max-width: 100%; max-height: 100%"]))
var attributes = [
"src": src,
"style": "max-width: 100%; max-height: 100%",
]
if let label = proxy.label {
attributes["alt"] = label
}
return AnyView(HTML("img", attributes))
} else {
return AnyView(Text("Invalid image name \(proxy.imageName). Options are \(lookup)"))
}
Expand Down

0 comments on commit 85d1752

Please sign in to comment.