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.
This commit is contained in:
David Taylor
2023-04-13 12:04:46 +01:00
committed by GitHub
parent 18c81958e5
commit e52f322cb5
6 changed files with 30 additions and 6 deletions

View File

@ -4,10 +4,12 @@ export default function getVideoAttributes(cooked) {
}
const url = cooked.querySelector("a")?.getAttribute("href");
const thumbnail = cooked.querySelector("img")?.getAttribute("src");
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 };
return { url, thumbnail, title, providerName, id, dominantColor };
}