Rework storage structs, link preview
This commit is contained in:
@ -3,7 +3,7 @@ struct PartialSvgImage: HtmlProducer {
|
||||
|
||||
let imagePath: String
|
||||
|
||||
let altText: String
|
||||
let altText: String?
|
||||
|
||||
let x: Int
|
||||
|
||||
@ -20,9 +20,16 @@ struct PartialSvgImage: HtmlProducer {
|
||||
return Double(width) / Double(height)
|
||||
}
|
||||
|
||||
private var imageAltText: String {
|
||||
guard let altText else {
|
||||
return ""
|
||||
}
|
||||
return " alt='\(altText.htmlEscaped())'"
|
||||
}
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<span class='content-image svg-image'>"
|
||||
result += "<img src='\(imagePath)#svgView(viewBox(\(x), \(y), \(width), \(height)))' loading='lazy' style='aspect-ratio:\(aspectRatio)' alt='\(altText)'/>"
|
||||
result += "<img src='\(imagePath)#svgView(viewBox(\(x), \(y), \(width), \(height)))' loading='lazy' style='aspect-ratio:\(aspectRatio)'\(imageAltText)/>"
|
||||
result += "</span>"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user