discourse/plugins/discourse-lazy-videos/assets/javascripts/lib/lazy-video-attributes.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
542 B
JavaScript
Raw Normal View History

export default function getVideoAttributes(cooked) {
if (!cooked.classList.contains("lazy-video-container")) {
return {};
}
const url = cooked.querySelector("a")?.getAttribute("href");
const img = cooked.querySelector("img");
const thumbnail = img?.getAttribute("src");
const dominantColor = img?.dataset?.dominantColor;
const title = cooked.dataset.videoTitle;
const providerName = cooked.dataset.providerName;
const id = cooked.dataset.videoId;
return { url, thumbnail, title, providerName, id, dominantColor };
}