如何在<video poster="…">
元素中获得poster
图像的图像尺寸(宽度和高度(?jQuery是可以接受的。
如果您的<video>
元素被引用为yourVideo
(例如const yourVideo = document.querySelector("video");
(,那么您可以通过poster
属性获取其poster
URL。这只是一个图像URL,所以像任何图像URL一样获取其尺寸:
const poster = Object.assign(new Image(), {
src: yourVideo.poster
});
poster.addEventListener("load", () => console.log(poster.width, poster.height));