Image improvements (#2513)

* Image improvements

* remove rate limits
This commit is contained in:
Nutomic 2022-10-28 14:34:40 +00:00 committed by GitHub
parent b0c3185663
commit 3b0be52e67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -45,7 +45,7 @@ struct Images {
#[derive(Deserialize)] #[derive(Deserialize)]
struct PictrsParams { struct PictrsParams {
format: Option<String>, format: Option<String>,
thumbnail: Option<String>, thumbnail: Option<i32>,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -130,8 +130,10 @@ async fn full_res(
let url = if params.format.is_none() && params.thumbnail.is_none() { let url = if params.format.is_none() && params.thumbnail.is_none() {
format!("{}image/original/{}", pictrs_config.url, name,) format!("{}image/original/{}", pictrs_config.url, name,)
} else { } else {
// Use jpg as a default when none is given // Take file type from name, or jpg if nothing is given
let format = params.format.unwrap_or_else(|| "jpg".to_string()); let format = params
.format
.unwrap_or_else(|| name.split('.').last().unwrap_or("jpg").to_string());
let mut url = format!("{}image/process.{}?src={}", pictrs_config.url, format, name,); let mut url = format!("{}image/process.{}?src={}", pictrs_config.url, format, name,);

View file

@ -10,6 +10,9 @@
admin_password: "lemmylemmy" admin_password: "lemmylemmy"
site_name: "lemmy-dev" site_name: "lemmy-dev"
} }
database: {
host: postgres
}
database: { database: {
host: "postgres" host: "postgres"