mirror of https://github.com/LemmyNet/lemmy.git
add setting disable_external_link_previews
parent
7fbfa48590
commit
706841950d
|
@ -49,6 +49,12 @@
|
||||||
#
|
#
|
||||||
# Requires pict-rs 0.5
|
# Requires pict-rs 0.5
|
||||||
image_proxy: false
|
image_proxy: false
|
||||||
|
# Don't store preview images for external links in pict-rs. Enabling this setting reduces
|
||||||
|
# storage usage. It may also be necessary in certain countries which don't allow copying images
|
||||||
|
# from newspaper articles, but only allow hotlinking.
|
||||||
|
#
|
||||||
|
# If this setting is enabled, the Opengraph image is directly returned as thumbnail.
|
||||||
|
disable_external_link_previews: false
|
||||||
}
|
}
|
||||||
# Email sending configuration. All options except login/password are mandatory
|
# Email sending configuration. All options except login/password are mandatory
|
||||||
email: {
|
email: {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{context::LemmyContext, post::LinkMetadata};
|
use crate::{context::LemmyContext, post::LinkMetadata, utils::proxy_image_link};
|
||||||
use encoding::{all::encodings, DecoderTrap};
|
use encoding::{all::encodings, DecoderTrap};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
error::{LemmyError, LemmyErrorType},
|
error::{LemmyError, LemmyErrorType},
|
||||||
|
@ -233,6 +233,10 @@ async fn generate_pictrs_thumbnail(
|
||||||
) -> Result<Url, LemmyError> {
|
) -> Result<Url, LemmyError> {
|
||||||
let pictrs_config = context.settings().pictrs_config()?;
|
let pictrs_config = context.settings().pictrs_config()?;
|
||||||
|
|
||||||
|
if pictrs_config.disable_external_link_previews {
|
||||||
|
return Ok(proxy_image_link(image_url.clone(), context)?);
|
||||||
|
}
|
||||||
|
|
||||||
// fetch remote non-pictrs images for persistent thumbnail link
|
// fetch remote non-pictrs images for persistent thumbnail link
|
||||||
// TODO: should limit size once supported by pictrs
|
// TODO: should limit size once supported by pictrs
|
||||||
let fetch_url = format!(
|
let fetch_url = format!(
|
||||||
|
|
|
@ -86,6 +86,14 @@ pub struct PictrsConfig {
|
||||||
/// Requires pict-rs 0.5
|
/// Requires pict-rs 0.5
|
||||||
#[default(false)]
|
#[default(false)]
|
||||||
pub image_proxy: bool,
|
pub image_proxy: bool,
|
||||||
|
|
||||||
|
/// Don't store preview images for external links in pict-rs. Enabling this setting reduces
|
||||||
|
/// storage usage. It may also be necessary in certain countries which don't allow copying images
|
||||||
|
/// from newspaper articles, but only allow hotlinking.
|
||||||
|
///
|
||||||
|
/// If this setting is enabled, the Opengraph image is directly returned as thumbnail.
|
||||||
|
#[default(false)]
|
||||||
|
pub disable_external_link_previews: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit abd40d4737fa732321fd7b62e42bbfcd51081cb6
|
Subproject commit e943f97fe481dc425acdebc8872bf1fdcabaf875
|
Loading…
Reference in New Issue