Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit a1bfb01

Browse files
committed
add ogp & twitter embed properties
1 parent 0d922d2 commit a1bfb01

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/endpoints/image.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ pub async fn get_view(
106106
.username;
107107

108108
let time = image.timestamp.and_utc().format("%Y/%m/%d %H:%M").to_string();
109-
109+
let png = PngInfo::create(&Bytes::from(image.file.clone())).await.unwrap();
110110
Ok(Html(
111111
include_str!("image_view.html")
112112
.replace("{filename}", &filename)
113113
.replace("{image_data}", &("data:image/png;base64,".to_string() + &STANDARD_NO_PAD.encode(image.file)))
114114
.replace("{image_url}", &image_url)
115+
.replace("{image_width}", &png.width.to_string())
116+
.replace("{image_height}", &png.height.to_string())
115117
.replace("{username}", &username)
116118
.replace(
117119
"{time}",

src/endpoints/image_view.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22
<html lang="en" data-theme="light">
33
<head>
44
<title>{filename} | AxolotlClient</title>
5-
<meta og:title="{filename}">
5+
<meta property="og:type" content="website" />
6+
<meta property="og:title" content="{filename} | AxolotlClient" />
7+
<meta property="og:image" content="{image_url}/raw" />
8+
<meta property="og:locale" content="en_US" />
9+
<meta property="og:url" content="{image_url}/view" />
10+
<meta property="og:description" content="{image_name} shared with AxolotlClient" />
11+
<meta property="og:image:height" content="{image_height}" />
12+
<meta property="og:image:width" content="{image_width}" />
13+
14+
<meta name="twitter:card" content="summary_large_image" />
15+
<meta name="twitter:img:src" content="{image_url}/raw" />
16+
<meta name="twitter:img:alt" content="{image_name} shared with AxolotlClient" />
17+
<meta name="twitter:image:width" content="{image_width}" />
18+
<meta name="twitter:image:height" content="{image_height}" />
619
<link rel="icon" href="https://axolotlclient.com/images/icon.png" />
720
<link rel="alternate" type="application/json+oembed"
821
href="{image_url}/oembed?format=json"

0 commit comments

Comments
 (0)