Reputation: 11
How to get the image dimensions (width and height) of the poster
image in a <video poster="…">
element? jQuery is acceptable.
Upvotes: 1
Views: 369
Reputation: 19485
If your <video>
element is referenced as yourVideo
(e.g. const yourVideo = document.querySelector("video");
), then you can get its poster
URL by the poster
property. This is just an image URL, so get its dimensions like with any image URL:
const poster = Object.assign(new Image(), {
src: yourVideo.poster
});
poster.addEventListener("load", () => console.log(poster.width, poster.height));
Upvotes: 2