fix image node cross origin problem

This commit is contained in:
wil committed 2024-10-22 12:34:55 -04:00
1 parent 5c6cc0be6f
commit ae649b61e6
3 files changed
+9 -2

No files matched your search

@@ -28,6 +28,10 @@ export interface MediaFile {
maybe_style_name: null | string;
public_bucket_path: string;
public_bucket_url: string;
media_links: {
cdn_url: string;
thumbnail_template: string;
};
cover_image: {
maybe_cover_image_public_bucket_path: null | string;
default_cover: {
+4 -2
View File
@@ -5,7 +5,7 @@ import { SelectionManager } from "../NodesManagers";
import { Position, Size, NodeData, TransformationData } from "../types";
import { NetworkedNode, UploadStatus } from "./NetworkedNode";
import { minNodeSize, NodeType, transparent } from "./constants";
import { NodeType, transparent } from "./constants";
import { NodeUtilities } from "./NodeUtilities";
interface ImageNodeContructor {
@@ -82,6 +82,7 @@ export class ImageNode extends NetworkedNode {
refPosition: Position;
}) {
const imageComponent = new Image();
imageComponent.crossOrigin = "anonymous";
imageComponent.onload = () => {
this.setProgress(0, UploadStatus.FILE_STAGED);
this.imageSize = {
@@ -114,6 +115,7 @@ export class ImageNode extends NetworkedNode {
private async loadImageFromUrl(mediaFileUrl: string) {
this.setProgress(75, UploadStatus.LOADING);
const newImage = new Image();
newImage.crossOrigin = "anonymous";
newImage.onerror = () => {
this.setProgress(90, UploadStatus.ERROR_ON_LOAD);
};
@@ -158,7 +160,7 @@ export class ImageNode extends NetworkedNode {
);
return;
}
this.mediaFileUrl = mediaFileResponse.data.public_bucket_url;
this.mediaFileUrl = mediaFileResponse.data.media_links.cdn_url;
this.loadImageFromUrl(this.mediaFileUrl);
}
+1
View File
@@ -115,6 +115,7 @@ export class TextNode extends BaseNode {
// Create a new Image object
const imageComponent = new Image();
imageComponent.crossOrigin = "anonymous";
imageComponent.onload = () => {
if (existingTransform) {
this.kNode.setAttrs({