diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index 3dabd22..55fa991 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -37,23 +37,29 @@ impl Media { pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value { let mut json = serde_json::to_value(self).unwrap(); - let (preview, html) = match self.file_path.rsplitn(2, '.').next().unwrap() { + let url = self.url(conn); + let (preview, html, md) = match self.file_path.rsplitn(2, '.').next().unwrap() { "png" | "jpg" | "jpeg" | "gif" | "svg" => ( - format!("\"{}\"", self.url(conn), self.alt_text, self.alt_text), - format!("\"{}\"", self.url(conn), self.alt_text, self.alt_text) + format!("\"{}\"", url, self.alt_text, self.alt_text), + format!("\"{}\"", url, self.alt_text, self.alt_text), + format!("![{}]({})", self.alt_text, url), ), "mp3" | "wav" | "flac" => ( - format!("", self.url(conn), self.alt_text), - format!("", self.url(conn), self.alt_text) + format!("", url, self.alt_text), + format!("", url, self.alt_text), + format!("", url, self.alt_text), ), "mp4" | "avi" | "webm" | "mov" => ( - format!("", self.url(conn), self.alt_text), - format!("", self.url(conn), self.alt_text) + format!("", url, self.alt_text), + format!("", url, self.alt_text), + format!("", url, self.alt_text), ), - _ => (String::new(), String::new()) + _ => (String::new(), String::new(), String::new()) }; json["html_preview"] = json!(preview); json["html"] = json!(html); + json["url"] = json!(url); + json["md"] = json!(md); json } diff --git a/templates/medias/details.html.tera b/templates/medias/details.html.tera index b9f8869..9910021 100644 --- a/templates/medias/details.html.tera +++ b/templates/medias/details.html.tera @@ -16,6 +16,13 @@ Your medias {{ media.html | safe }}
{{ media.alt_text }}
+
+

+ {{ "Markdown code" | _ }} + {{ "Copy it in your articles to insert this media." }} +

+ {{ media.md }} +
Use as avatar Delete