Issue #2115💬 AnsweredOpened July 3, 2019by vish43950 reactions

How I can get AssetManger selected image from outside the editor

快速解答by vish4395

I found the solution It helps me to use asset manager for changing the image field outside the editor. Is this is the right way to use it?

Read full answer below ↓

Question

Hello, I want to get selected image from AssetManger model. Thank You.

Answers (2)

vish4395July 3, 2019

I found the solution

function getGrapeJsAssetManager(editor,targetElem,targetInput){
  editor.runCommand('open-assets', {
              target: targetElem,
              onSelect: function onSelect(t) {
				targetElem.attr('src',t.id);
				targetInput.val(t.id);
              },
              onClick: function onSelect(t) {
				targetElem.attr('src',t.id);
				targetInput.val(t.id);
              }
            });
}

It helps me to use asset manager for changing the image field outside the editor. Is this is the right way to use it?

artfJuly 12, 2019

Yes, but probably I'd remove onClick function as it's already done by onSelect

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.