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 GitHub
parent f5066b1f0b
commit a051772fff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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

@ -354,9 +354,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)]