diff --git a/app/public/static/video_embed.js b/app/public/static/video_embed.js
index b32c3563..9ff2e06d 100644
--- a/app/public/static/video_embed.js
+++ b/app/public/static/video_embed.js
@@ -1,24 +1,32 @@
document.querySelectorAll(".video-embed").forEach(ele => {
- const url = new URL(ele.getAttribute("href"));
+ try {
+ const href = ele.getAttribute("href");
+ const url = new URL(href);
- if (url.host == "www.youtube.com") {
- ele.addEventListener("click", () => {
- ele.parentNode.classList.add("d-block");
- ele.classList.add("embed-responsive");
- ele.classList.add("embed-responsive-16by9");
- ele.innerHTML = `
- `;
+ if (url.host == "www.youtube.com") {
+ ele.addEventListener("click", () => {
+ ele.parentNode.classList.add("d-block");
+ ele.classList.add("embed-responsive");
+ ele.classList.add("embed-responsive-16by9");
+ ele.innerHTML = `
+ `;
- const embedURL = new URL("https://www.youtube.com/");
- embedURL.pathname = "/embed/" + url.searchParams.get("v");
- embedURL.searchParams.set("autoplay", "1");
+ const embedURL = new URL("https://www.youtube.com/");
+ embedURL.pathname = "/embed/" + url.searchParams.get("v");
+ embedURL.searchParams.set("autoplay", "1");
- const iframe = ele.children[0];
- iframe.setAttribute("src", embedURL);
- });
- ele.removeAttribute("href");
+ const iframe = ele.children[0];
+ iframe.setAttribute("src", embedURL);
+ });
+
+ ele.setAttribute("data-src", href);
+ ele.removeAttribute("href");
+ }
+ } catch (e) {
+ console.error(url);
+ return;
}
});