This commit is contained in:
Mylloon 2024-03-31 20:34:19 +02:00
parent 0e6b66d52f
commit 0a062babd9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -205,12 +205,17 @@ fn fix_local_img(path: &str, html: String) -> String {
if let Some(img_src) = Path::new(path).parent() {
let img_path = img_src.join(src);
let file = fs::read_to_string(&img_path).unwrap();
let encoded = general_purpose::STANDARD.encode(file);
let mime_type = mime_guess::from_path(img_path)
.first_or_octet_stream()
.to_string();
el.set_attribute("src", &format!("data:{};base64,{}", mime_type, encoded))
.unwrap();
let image = general_purpose::STANDARD.encode(file);
el.set_attribute(
"src",
&format!(
"data:{};base64,{}",
mime_guess::from_path(img_path).first_or_octet_stream(),
image
),
)
.unwrap();
}
}