Skip to content

Commit 946adb2

Browse files
thumbnail size optional
1 parent c213bbf commit 946adb2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/api/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub struct Article {
2727
#[derive(Deserialize)]
2828
pub struct Image {
2929
pub caption: Option<String>,
30-
pub width: u16,
31-
pub height: u16,
30+
pub width: Option<u16>,
31+
pub height: Option<u16>,
3232
pub resizer_url: String,
3333
}
3434

src/render/images.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ pub fn render_image(thumbnail: &Image, settings: &Settings) -> maud::Markup {
2020
};
2121
let mut srcset = String::new();
2222
for width in RESIZE_STEPS {
23-
if width > thumbnail.width {
24-
break;
23+
if let Some(w) = thumbnail.width {
24+
if width > w {
25+
break;
26+
}
2527
}
2628
srcset.push_str(&format!("{url}&width={width}&quality=80 {width}w,"));
2729
}
@@ -30,7 +32,7 @@ pub fn render_image(thumbnail: &Image, settings: &Settings) -> maud::Markup {
3032
figure {
3133
img src=(url)
3234
srcset=(srcset)
33-
width=(thumbnail.width) height=(thumbnail.height)
35+
width=[thumbnail.width] height=[thumbnail.height]
3436
alt="";
3537
@if let Some(caption) = &thumbnail.caption {
3638
figcaption { i { (caption) } }

0 commit comments

Comments
 (0)