Add configuration for image size.
This commit is contained in:
parent
1f25982b84
commit
24f907b59b
|
@ -26,12 +26,14 @@
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Generator {
|
pub struct Generator {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
pub image_size: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Generator {
|
impl Default for Generator {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_url: "www.gravatar.com".to_string(),
|
base_url: "www.gravatar.com".to_string(),
|
||||||
|
image_size: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,4 +82,19 @@ impl Generator {
|
||||||
..self
|
..self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configures the Generator to include a `s=<image size>` in the URL.
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use gravatar_rs::Generator;
|
||||||
|
///
|
||||||
|
/// // Get 128px images instead of the default 80px.
|
||||||
|
/// Generator::default().set_image_size(128);
|
||||||
|
/// ```
|
||||||
|
pub fn set_image_size(self, image_size: i32) -> Self {
|
||||||
|
Self {
|
||||||
|
image_size: Some(image_size),
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue