web: Added media previewing
This commit is contained in:
parent
ca3668eea7
commit
318cbe98ea
4 changed files with 48 additions and 3 deletions
|
@ -113,3 +113,19 @@ function click_event(el) {
|
|||
console.info(`thread to open: ${el.dataset.eid}`);
|
||||
switch_view("thread");
|
||||
}
|
||||
|
||||
/* open_media_preview presents a modal to display an image via "url".
|
||||
*/
|
||||
function open_media_preview(url, type) {
|
||||
const el = find_node("#media-preview");
|
||||
el.classList.remove("closed");
|
||||
find_node("img", el).src = url;
|
||||
// TODO handle different medias such as audio and video
|
||||
// TODO add loading state & error checking
|
||||
}
|
||||
|
||||
/* close_media_preview closes any present media modal.
|
||||
*/
|
||||
function close_media_preview() {
|
||||
find_node("#media-preview").classList.add("closed");
|
||||
}
|
||||
|
|
|
@ -169,9 +169,7 @@ function linkify(text, show_media) {
|
|||
let html;
|
||||
if (show_media && is_img_url(parsed.pathname)) {
|
||||
html = `
|
||||
<a target="_blank" href="${url}">
|
||||
<img class="inline-img" src="${url}"/>
|
||||
</a>
|
||||
<img class="inline-img clickable" src="${url}" onclick="open_media_preview('${url}', 'image')"/>
|
||||
`;
|
||||
} else if (show_media && is_video_url(parsed.pathname)) {
|
||||
html = `
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue