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

WORLDSERVICE-354: Portrait Video Thumbnail #12411

Open
wants to merge 6 commits into
base: latest
Choose a base branch
from

Conversation

Louis-Matsika
Copy link
Contributor

@Louis-Matsika Louis-Matsika commented Feb 17, 2025

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

  • Adds code to check for portrait in both the first and second position of the array.
  • Adds unit tests to cover new cases

Testing

  1. http://localhost:7080/indonesia/articles/c391p84jgdno?renderer_env=live

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@HarveyPeachey HarveyPeachey marked this pull request as ready for review February 19, 2025 12:10
@karinathomasbbc karinathomasbbc changed the title 354 pv thumbnail WORLDSERVICE-354: Portrait Video Thumbnail Feb 19, 2025
Comment on lines 63 to 64
(ORIENTATION_MAPPING[versionsBlock?.types?.[0]] ||
ORIENTATION_MAPPING[versionsBlock?.types?.[1]]) ??
Copy link
Contributor

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;

Copy link
Contributor

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

Copy link
Contributor

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;

Copy link
Contributor

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

Copy link
Contributor

@HarveyPeachey HarveyPeachey Feb 19, 2025

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

Copy link
Contributor

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];

Copy link
Contributor

Choose a reason for hiding this comment

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

That would work!

Copy link
Contributor

@Isabella-Mitchell Isabella-Mitchell left a 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:

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.

Comment on lines 63 to 64
(ORIENTATION_MAPPING[versionsBlock?.types?.[0]] ||
ORIENTATION_MAPPING[versionsBlock?.types?.[1]]) ??
Copy link
Contributor

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;

@HarveyPeachey HarveyPeachey self-assigned this Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants