diff --git a/src/api/markdown.rs b/src/api/markdown.rs index b6a0fec..9107ab9 100644 --- a/src/api/markdown.rs +++ b/src/api/markdown.rs @@ -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 已转义过,这里直接用) diff --git a/src/components/image_viewer.rs b/src/components/image_viewer.rs index cc01da9..6da7981 100644 --- a/src/components/image_viewer.rs +++ b/src/components/image_viewer.rs @@ -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); } } }