Skip to content

Commit

Permalink
Code Quality: Use preloadImage in wp-dashboard (#12466)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey authored and swissspidy committed Oct 14, 2022
1 parent df5a9ac commit a6bcd55
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 a6bcd55

Please sign in to comment.