aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Configuration.md6
-rw-r--r--src/html.rs15
2 files changed, 14 insertions, 7 deletions
diff --git a/Configuration.md b/Configuration.md
index e7b48f4..e87678d 100644
--- a/Configuration.md
+++ b/Configuration.md
@@ -116,8 +116,10 @@ HEADER="This string will show up at the top of my proxied capsule."
Embed images in the HTML response if a link to an image is found
-Any non-empty value will enable this feature.
+A value of `1` will enable this feature, while keeping link to the image.
+
+Any non-empty value other than `1` will enable this feature, while removing the link to the image.
```dotenv
-EMBED_IMAGES=true
+EMBED_IMAGES=2
```
diff --git a/src/html.rs b/src/html.rs
index ebe31d9..b86c496 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -112,7 +112,7 @@ pub fn from_gemini(
}
}
- if var("EMBED_IMAGES").is_ok() {
+ if let Ok(embed_images) = var("EMBED_IMAGES") {
if let Some(extension) = std::path::Path::new(&href).extension() {
if extension == "png"
|| extension == "jpg"
@@ -121,11 +121,16 @@ pub fn from_gemini(
|| extension == "webp"
|| extension == "svg"
{
+ if embed_images == "1" {
+ html.push_str(&format!(
+ "<p><a href=\"{}\">{}</a> <i>Embedded below</i></p>\n",
+ href,
+ safe(&text.clone().unwrap_or_default()),
+ ));
+ }
+
html.push_str(&format!(
- "<p><a href=\"{}\">{}</a> <i>Embedded below</i></p>\n<p><img \
- src=\"{}\" alt=\"{}\" /></p>\n",
- href,
- safe(&text.clone().unwrap_or_default()),
+ "<p><img src=\"{}\" alt=\"{}\" /></p>\n",
safe(&href),
safe(&text.clone().unwrap_or_default())
));