Skip to content

[MWPW-170376] Preflight assets tab updates #4510

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

Merged

Conversation

overmyheadandbody
Copy link
Contributor

@overmyheadandbody overmyheadandbody commented Jul 7, 2025

This adapts the Assets checks from the Preflight suite to also check videos, not only images. To keep a god balance between performance and quality, a factor of 1 has been chosen for video assets; meaning a video's dimensions should be at least those of its container. It considers:

  • videos uploaded through Sharepoint, used in regular video tags. These are marked as Video (Sharepoint);
  • MPC videos, embedded through iframe tags. These are marked as Video (MPC);
  • videos uploaded through MPC with their source used in regular video tags. These are marked as Video (MPC source).

A couple of additional checks can populate a new Notes field, as suggested here, should one of these conditions be met:

  • if a Sharepoint video has relevant audio data;
  • if an MPC MP4 video source is used as a background video.

The Assets logic had to be refactored, as the logic got more complex with adding video checks. Another small change was made to the video decoration logic to ensure a source is only added if one doesn't already exist. This is needed, since the Preflight logic forces video load, even when outside the viewport, in order to perform the relevant size calculations. When a user eventually scrolls the page, we need to ensure we don't duplicate the video's source child.

Resolves: MWPW-170376

Test URLs:

@overmyheadandbody overmyheadandbody requested a review from a team as a code owner July 7, 2025 13:46
Copy link
Contributor

aem-code-sync bot commented Jul 7, 2025

@overmyheadandbody
Copy link
Contributor Author

@overmyheadandbody overmyheadandbody force-pushed the preflight-assets-updates branch 2 times, most recently from ab6cfa9 to 606893c Compare July 7, 2025 14:26
@overmyheadandbody overmyheadandbody force-pushed the preflight-assets-updates branch from 606893c to 95da523 Compare July 7, 2025 14:37
@@ -22,110 +212,53 @@ export async function checkImageDimensions(url, area) {
return JSON.parse(JSON.stringify(cachedResult));
}

const allImages = [...area.querySelectorAll('main picture img')];
if (!allImages.length) {
const allAssets = [...area.querySelectorAll('main picture img, main video, main .adobetv')];
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll look into this for a follow-up contribution.

const isFullWidthAsset = offsetWidth >= viewportWidth;

// Define the ideal factor depending on the asset's display width
let idealFactor = isFullWidthAsset ? 1.5 : 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should define the values as constants (e.g. IDEAL_IMAGE_FACTOR, IDEAL_FULL_WIDTH_IMAGE_FACTOR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reason for not doing this is simply because the values are never re-used. Using constants would add a few more bytes to the size and use (a bit of) additional memory, with no obvious benefit. It's of course negligible, especially since this isn't customer-facing, so both approaches should be acceptable.

@SilviuLCF SilviuLCF self-requested a review July 9, 2025 11:45
Copy link

@SilviuLCF SilviuLCF left a comment

Choose a reason for hiding this comment

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

@milo-pr-merge milo-pr-merge bot merged commit 96338e8 into adobecom:stage Jul 9, 2025
17 of 18 checks passed
@github-actions github-actions bot mentioned this pull request Jul 9, 2025
ajullal pushed a commit to ajullal/milo that referenced this pull request Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants