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>"
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,18 @@ struct SimpleImage: HtmlProducer {
|
||||
|
||||
let imagePath: String
|
||||
|
||||
let altText: String
|
||||
let altText: String?
|
||||
|
||||
private var imageAltText: String {
|
||||
guard let altText else {
|
||||
return ""
|
||||
}
|
||||
return " alt='\(altText.htmlEscaped())'"
|
||||
}
|
||||
|
||||
func populate(_ result: inout String) {
|
||||
result += "<div class='content-image svg-image'>"
|
||||
result += "<img src='\(imagePath)' loading='lazy' alt='\(altText)'/>"
|
||||
result += "<img src='\(imagePath)' loading='lazy'\(imageAltText)/>"
|
||||
result += "</div>"
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,16 @@ struct ModelViewer {
|
||||
|
||||
let file: String
|
||||
|
||||
let description: String
|
||||
let description: String?
|
||||
|
||||
private var imageAltText: String {
|
||||
guard let description else {
|
||||
return ""
|
||||
}
|
||||
return " alt='\(description.htmlEscaped())'"
|
||||
}
|
||||
|
||||
var content: String {
|
||||
"<model-viewer alt='\(description)' src='\(file)' ar shadow-intensity='1' camera-controls touch-action='pan-y'></model-viewer>"
|
||||
"<model-viewer\(imageAltText) src='\(file)' ar shadow-intensity='1' camera-controls touch-action='pan-y'></model-viewer>"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user