From a24d584852fe8c1490cdaa398a062667c37b91c4 Mon Sep 17 00:00:00 2001 From: Tsachi Shlidor Date: Thu, 7 Mar 2024 12:36:23 +0200 Subject: [PATCH] fix: poster image for raw URLs (#573) --- src/plugins/cloudinary/index.js | 16 ++++++++-------- .../models/video-source/video-source.js | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/cloudinary/index.js b/src/plugins/cloudinary/index.js index 635db8f3..ccc97fd9 100644 --- a/src/plugins/cloudinary/index.js +++ b/src/plugins/cloudinary/index.js @@ -255,9 +255,10 @@ class CloudinaryContext { const refresh = () => { const src = this.source(); - const { posterColor } = this.player.cloudinary.posterOptions(); - if (posterColor) { - this.disablePoster(posterColor); + const posterOptions = Object.assign({}, this.player.cloudinary.posterOptions(), src.getInitOptions().poster); + + if (posterOptions.posterColor) { + this.disablePoster(posterOptions.posterColor); } else if (src.poster()) { this.player.poster(src.poster().url()); } @@ -298,14 +299,13 @@ class CloudinaryContext { const posterOptionsForCurrent = () => { const opts = assign({}, this.posterOptions()); - if (opts.transformation) { - if ((opts.transformation.width || opts.transformation.height) && !opts.transformation.crop) { - opts.transformation.crop = 'scale'; - } - } opts.transformation = opts.transformation || {}; + if ((opts.transformation.width || opts.transformation.height) && !opts.transformation.crop) { + opts.transformation.crop = 'scale'; + } + // Set poster dimensions to player actual size. // (unless they were explicitly set via `posterOptions`) const playerEl = this.player.el(); diff --git a/src/plugins/cloudinary/models/video-source/video-source.js b/src/plugins/cloudinary/models/video-source/video-source.js index 9c76a07a..7e7f2b62 100644 --- a/src/plugins/cloudinary/models/video-source/video-source.js +++ b/src/plugins/cloudinary/models/video-source/video-source.js @@ -169,6 +169,10 @@ class VideoSource extends BaseSource { ({ publicId, options } = normalizeOptions(publicId, options, { tolerateMissingId: true })); + if (!publicId && this.isRawUrl) { + return null; + } + if (!publicId) { publicId = this.publicId(); options = assign({}, options, DEFAULT_POSTER_PARAMS);