-
Notifications
You must be signed in to change notification settings - Fork 232
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
WORLDSERVICE-354: Portrait Video Thumbnail #12411
base: latest
Are you sure you want to change the base?
Conversation
(ORIENTATION_MAPPING[versionsBlock?.types?.[0]] || | ||
ORIENTATION_MAPPING[versionsBlock?.types?.[1]]) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be improved in any way with array destructuring & some clever checking whether the orientation is already in the mapping object?
const [orientationType] = versionsBlock?.types?.filter(type => Object.keys(ORIENTATION_MAPPING).includes(type));
const orientation = ORIENTATION_MAPPING[orientationType] || ORIENTATION_MAPPING.Original;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this will definitely work, the only reason why we've targeted the specific positions in the types array is because I didn't know what the schema could be for types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do a find
instead of a filter
... so that it would just match the first one it matches. But it's also OK to leave as is as like you say, we don't know what else might be in that array...
const orientationType = versionsBlock?.types?.find(type => Object.keys(ORIENTATION_MAPPING).includes(type));
const orientation = ORIENTATION_MAPPING[orientationType] || ORIENTATION_MAPPING.Original;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just switch it over to this as it's cleaner and is basically the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh wait undefined can't be used as an index selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you reckon something like this:
const orientationType =
versionsBlock?.types?.find(type =>
Object.keys(ORIENTATION_MAPPING).includes(type),
) ?? 'Original';
const orientation = ORIENTATION_MAPPING[orientationType];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can see this working as expected. Thanks :)
Tested:
- 'Editorial portrait' (renders correctly): http://localhost.bbc.com:7080/indonesia/articles/c391p84jgdno?renderer_env=live
- 'Editorial' and 'Original' landscape videos (no change): http://localhost.bbc.com:7080/persian/articles/c5y3x5jlpyko?renderer_env=live
- 'Portrait' video (no change): http://localhost.bbc.com:7080/mundo/articles/c1xv2q1gewvo?renderer_env=test
I can see that the video asset in is distorted in Castaway (the tools Editorial use to upload videos). So agree it might be something in upload or playback.
(ORIENTATION_MAPPING[versionsBlock?.types?.[0]] || | ||
ORIENTATION_MAPPING[versionsBlock?.types?.[1]]) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do a find
instead of a filter
... so that it would just match the first one it matches. But it's also OK to leave as is as like you say, we don't know what else might be in that array...
const orientationType = versionsBlock?.types?.find(type => Object.keys(ORIENTATION_MAPPING).includes(type));
const orientation = ORIENTATION_MAPPING[orientationType] || ORIENTATION_MAPPING.Original;
Resolves JIRA WORLDSERVICE-354
Overall changes
Adds code to detect for ["Editorial", "Portrait"].
This doesn't fix the issue with video aspect ratio appearing weird when playing some videos:
https://www.bbc.com/persian/articles/c149pnldynxo
Need to message the smp team about this, if it's something we can change on our end, or something editorial needs to do when uploading a video.
Code changes
Testing
Helpful Links
Add Links to useful resources related to this PR if applicable.
Coding Standards
Repository use guidelines