discourse/plugins/discourse-lazy-videos/assets/javascripts/lib/lazy-video-attributes.js
David Taylor e52f322cb5
UX: Use dominant color while loading onebox images (#21091)
When we "pull hotlinked images" on onebox images, they are added to the uploads table and their dominant color is calculated. This commit adds the data to the HTML so that it can be used by the client in the same way as non-onebox images. It also adds specific handling to the new `discourse-lazy-videos` plugin.
2023-04-13 12:04:46 +01:00

16 lines
542 B
JavaScript

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 };
}