Skip to content

Commit

Permalink
Fixed ObjectURL causing broken images
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptizism committed Sep 18, 2023
1 parent c1920e1 commit c1edd37
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/ImageHolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ const ImageHolder = () => {
const item = items[i];
if (item.type.indexOf("image") !== -1) {
const blob = item.getAsFile();
if (blob) {
const imageUrl = URL.createObjectURL(blob);
let reader = new FileReader();
reader.readAsDataURL(blob || new Blob());
reader.onloadend = function() {
let base64data : any = reader.result;
setImages((prevImages) => [
...prevImages,
{ id: new Date().getTime(), url: imageUrl }
{ id: new Date().getTime(), url: base64data }
]);
}
}
Expand Down

0 comments on commit c1edd37

Please sign in to comment.