fix(blur-up): use slash separator for aspect-ratio (--ar W / H)
根因: CSS aspect-ratio 合法语法是 "width / height"(斜杠分隔),
但 --ar 生成时用了冒号 ":"(--ar:2974:2066)。冒号在 CSS 里是声明分隔符,
2974:2066 被判非法值, aspect-ratio 退化为 auto, 容器高度为 0, 图片不可见.
控制台数据证实: aspectRatio:"auto", clientHeight:0, arVar:"2974:2066"
修复: markdown.rs(正文图) 和 image_viewer.rs(封面) 两处把
{}:{} 改成 {} / {}. CSS 规则 aspect-ratio: var(--ar) 不变,
var 展开后变成合法的 "2974 / 2066".
This commit is contained in:
parent
0413e539fe
commit
6e98c2abfa
@ -232,8 +232,9 @@ fn wrap_images_with_blur(html: &str) -> String {
|
||||
.unwrap_or("");
|
||||
|
||||
// 查 dimensions,算 aspect-ratio
|
||||
// 注意:CSS aspect-ratio 用斜杠分隔(width / height),不是冒号
|
||||
let ar_style = crate::api::image::get_image_dimensions(rel_path)
|
||||
.map(|(w, h)| format!(" style=\"--ar:{}:{};\"", w, h))
|
||||
.map(|(w, h)| format!(" style=\"--ar:{} / {};\"", w, h))
|
||||
.unwrap_or_default();
|
||||
|
||||
// alt 转义(src/alt 来自 markdown,pulldown-cmark 已转义过,这里直接用)
|
||||
|
||||
@ -77,7 +77,8 @@ pub fn ImageViewer(
|
||||
.map(|p| p.split('?').next().unwrap_or(p))
|
||||
{
|
||||
if let Some((w, h)) = crate::api::image::get_image_dimensions(rel) {
|
||||
s = format!("--ar:{}:{};", w, h);
|
||||
// 注意:CSS aspect-ratio 用斜杠分隔(width / height),不是冒号
|
||||
s = format!("--ar:{} / {};", w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user