Skip to content

Commit

Permalink
Use preloadImage in wp-dashboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Oct 13, 2022
1 parent d87cf2a commit f560584
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
MIN_IMG_HEIGHT,
useConfig,
} from '@googleforcreators/dashboard';
import { preloadImage } from '@googleforcreators/media';

/**
* Internal dependencies
Expand Down Expand Up @@ -212,16 +213,7 @@ function EditorSettings() {
return;
}

imagePromises.push(
new Promise((resolve, reject) => {
const img = new Image();

img.onload = () => resolve(img);
img.onerror = () => reject(new Error(file.name));

img.src = URL.createObjectURL(file);
})
);
imagePromises.push(preloadImage(URL.createObjectURL(file)));
});

if (!allFileSizesWithinMaxUpload) {
Expand Down

0 comments on commit f560584

Please sign in to comment.