Resize post thumbnails (fixes #4053) (#5107)

* Resize post thumbnails (fixes #4053)

* 256px
This commit is contained in:
Nutomic 2024-10-08 10:24:55 +02:00 committed by Felix Ableitner
parent 0ba0d0f9b3
commit 10a28e78d9
3 changed files with 9 additions and 2 deletions

View file

@ -75,6 +75,8 @@
"ProxyAllImages"
# Timeout for uploading images to pictrs (in seconds)
upload_timeout: 30
# Resize post thumbnails to this maximum width/height.
max_thumbnail_size: 256
}
# Email sending configuration. All options except login/password are mandatory
email: {

View file

@ -353,9 +353,10 @@ async fn generate_pictrs_thumbnail(image_url: &Url, context: &LemmyContext) -> L
// fetch remote non-pictrs images for persistent thumbnail link
// TODO: should limit size once supported by pictrs
let fetch_url = format!(
"{}image/download?url={}",
"{}image/download?url={}&resize={}",
pictrs_config.url,
encode(image_url.as_str())
encode(image_url.as_str()),
context.settings().pictrs_config()?.max_thumbnail_size
);
let res = context

View file

@ -90,6 +90,10 @@ pub struct PictrsConfig {
/// Timeout for uploading images to pictrs (in seconds)
#[default(30)]
pub upload_timeout: u64,
/// Resize post thumbnails to this maximum width/height.
#[default(256)]
pub max_thumbnail_size: u32,
}
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document, PartialEq)]