diff --git a/packages/story-editor/src/app/media/media3p/useFetchMediaEffect.js b/packages/story-editor/src/app/media/media3p/useFetchMediaEffect.js index cf8f9764e8d0..c71495a78826 100644 --- a/packages/story-editor/src/app/media/media3p/useFetchMediaEffect.js +++ b/packages/story-editor/src/app/media/media3p/useFetchMediaEffect.js @@ -19,6 +19,7 @@ */ import { useEffect, useRef } from '@googleforcreators/react'; import { useSnackbar } from '@googleforcreators/design-system'; +import { trackError } from '@googleforcreators/tracking'; /** * Internal dependencies @@ -99,6 +100,9 @@ export default function useFetchMediaEffect({ nextPageToken, }); } catch (e) { + // eslint-disable-next-line no-console -- We want to surface this error. + console.error(e); + trackError('fetch_media3p', e.message); fetchMediaError({ provider, pageToken }); showSnackbar({ message: PROVIDERS[provider].fetchMediaErrorMessage, diff --git a/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js b/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js index 2025b12a47c7..411ef490fa4a 100644 --- a/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js +++ b/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js @@ -197,6 +197,11 @@ function getVideoUrls(m) { } function sortMediaBySize(m, mediaUrls) { + // https://github.com/GoogleForCreators/web-stories-wp/issues/12083 + if (mediaUrls.length < 1) { + return []; + } + const sortedUrls = mediaUrls.sort((x, y) => (y.width ?? 0) - (x.width ?? 0)); const originalSize = getOriginalSize(sortedUrls); return sortedUrls.map((u) =>