diff --git a/app/assets/javascripts/discourse/app/initializers/post-decorations.js b/app/assets/javascripts/discourse/app/initializers/post-decorations.js index 7b7d543aa87..2146cbbe2a6 100644 --- a/app/assets/javascripts/discourse/app/initializers/post-decorations.js +++ b/app/assets/javascripts/discourse/app/initializers/post-decorations.js @@ -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 } + ); + } }); } };