Skip to content

Image browse dialog is not opening. #6151

Closed Answered by prajyod
prajyod asked this question in Q&A
Discussion options

You must be logged in to vote

I have overcomplicated the code I think, it is fairly simple to upload image from another source.
inside grapejs.init

interface ImageData{
  id: number;
  title: string;
  url: string;
}
const fetchImages = async() => {
  const response = await fetch('http://127.0.0.1:8001/fetch-images/');
  
const images: ImageData[] = await response.json();

  const assetManager = editor.AssetManager;
  assetManager.add(images.map(image => ({
    type: 'image',
    src: `http://127.0.0.1:8001/${image.url}`,
    title: image.title,
  })));
};

fetchImages();

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by prajyod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant