mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 13:03:45 +08:00
e52f322cb5
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.
16 lines
542 B
JavaScript
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 };
|
|
}
|