Copy poster when creating new media element for YouTube and Vimeo (needed for #1018)

This commit is contained in:
Albin Larsson 2018-06-15 22:57:16 +02:00
parent f1c4752036
commit aab2817ddc
2 changed files with 10 additions and 2 deletions

View File

@ -119,8 +119,11 @@ const vimeo = {
iframe.setAttribute('allowtransparency', '');
iframe.setAttribute('allow', 'autoplay');
// Get poster, if already set
const { poster } = player;
// Inject the package
const wrapper = createElement('div', { class: player.config.classNames.embedContainer });
const wrapper = createElement('div', { poster, class: player.config.classNames.embedContainer });
wrapper.appendChild(iframe);
player.media = replaceElement(wrapper, player.media);

View File

@ -158,7 +158,12 @@ const youtube = {
// Replace the <iframe> with a <div> due to YouTube API issues
const videoId = parseId(source);
const id = generateId(player.provider);
const container = createElement('div', { id });
// Get poster, if already set
const { poster } = player;
// Replace media element
const container = createElement('div', { id, poster });
player.media = replaceElement(container, player.media);
// Set poster image