FIX: Trick Safari into loading video previews (#10244)

This commit is contained in:
Penar Musaraj 2020-07-15 18:14:14 -04:00 committed by GitHub
parent fa612fca82
commit 9e160f58ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -38,6 +38,23 @@ export default {
},
{ id: "discourse-audio" }
);
const caps = container.lookup("capabilities:main");
if (caps.isSafari) {
api.decorateCookedElement(
elem => {
const video = elem.querySelector("video");
if (video && !video.poster) {
const source = video.querySelector("source");
if (source) {
// this tricks Safari into loading the video preview
source.parentElement.load();
}
}
},
{ id: "safari-video-poster", afterAdopt: true }
);
}
});
}
};