diff --git a/common/file-utilities.js b/common/file-utilities.js index bbd92f5b..e902897e 100644 --- a/common/file-utilities.js +++ b/common/file-utilities.js @@ -20,10 +20,14 @@ const loadImage = async (src) => }); const getImageData = (image) => { + let ratio = Math.min(100 / image.height, 100 / image.width); + image.height = image.height * ratio; + image.width = image.width * ratio; const canvas = document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; const context = canvas.getContext("2d"); + context.scale(ratio, ratio); context.drawImage(image, 0, 0); return context.getImageData(0, 0, image.width, image.height); }; @@ -150,7 +154,7 @@ export const upload = async ({ file, context, bucketName, routes, excludeFromLib if (!res || res.error || !res.data) { if (context) { - context.setState({ + await context.setState({ fileLoading: { ...context.state.fileLoading, [`${file.lastModified}-${file.name}`]: { diff --git a/components/core/SlateMediaObjectPreview.js b/components/core/SlateMediaObjectPreview.js index e7694191..d6a8da6a 100644 --- a/components/core/SlateMediaObjectPreview.js +++ b/components/core/SlateMediaObjectPreview.js @@ -61,8 +61,6 @@ const STYLES_BLUR_CONTAINER = css` `; export default class SlateMediaObjectPreview extends React.Component { - count = 0; - static defaultProps = { charCap: 30, }; @@ -87,7 +85,6 @@ export default class SlateMediaObjectPreview extends React.Component { }; loadImage = async (url) => { - this.count += 1; const img = new Image(); img.onload = () => this.setState({ showImage: true }); img.src = url;