Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: poster image for raw URLs #573

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/plugins/cloudinary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +260 to +261
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure i understand the logic here even before your change... like if posterColor is supplied as an option then we continue to disable it, why is that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of disablePoster you can call it resetPosterAndSetPosterColorIfConfigured :)
I really don't like the whole poster flow, but like you said yesterday, we shouldn't/can't fix everything now

} else if (src.poster()) {
this.player.poster(src.poster().url());
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/cloudinary/models/video-source/video-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading