web-stories-wp
web-stories-wp copied to clipboard
Media3P: Add hardening for missing media URLs
Context
The third part media / Gif tab is failing to load -- it throws a snackbar error.
Summary
Updates sortMediaBySize
to early return if media urls don't get passed to the parameters.
In this case after filtering we can end up with an empty array
const webmSizes = sortMediaBySize(
m,
m.videoUrls.filter(({ mimeType }) => mimeType === 'image/webm')
);
causing the eventual width / height check to fail
originalWidth: mediaUrls[0].width,
originalHeight: mediaUrls[0].height,
See: https://github.com/GoogleForCreators/web-stories-wp/issues/12083#issuecomment-1209827399
Relevant Technical Choices
To-do
User-facing changes
Testing Instructions
- [ ] This is a non-user-facing change and requires no QA
This PR can be tested by following these steps:
- "fresh load of the page" (full reload)
- Visit the Gif tab
- Scroll to load images - note the tab loads and doesn't throw an error.
Reviews
Does this PR have a security-related impact?
no
Does this PR change what data or activity we track or use?
Added error tracking for for fetch media
Does this PR have a legal-related impact?
no
Checklist
- [x] This PR addresses an existing issue and I have linked this PR to it in ZenHub
- [x] I have tested this code to the best of my abilities
- [ ] I have verified accessibility to the best of my abilities (docs)
- [ ] I have verified i18n and l10n (translation, right-to-left layout) to the best of my abilities
- [ ] This code is covered by automated tests (unit, integration, and/or e2e) to verify it works as intended (docs)
- [ ] I have added documentation where necessary
- [x] I have added a matching
Type: XYZ
label to the PR
Fixes #12083
@swissspidy I added a trackError to help surface anything that might come up in the future.
Plugin builds for f0422600a0922adc573c657941398411fd6c4f06 are ready :bellhop_bell:!
- Download development build
- Download production build