Issue #771💬 AnsweredOpened January 17, 2018by Deepak8130 reactions

Image src is not updating

Quick answerby ryandeba

Hi @Deepak813, I'm not sure where templateHTML is coming from in your example...is the src on your image set correctly in that variable? In any case, selecting an image and running this code seems to work fine for me in the demo: editor.getSelected().set("src", "http://via.placeholder.com/350x150")

Read full answer below ↓

Question

Hi @artf,

I have updated the image src using below code: editor.getSelected().set('attributes', {'src': image_Url});

but when i set all the html using below code: editor.setComponents(templateHTML); then image src not updating in HTMLcomponent.

Please let us know about the same.

Answers (3)

ryandebaJanuary 18, 2018

Hi @Deepak813, I'm not sure where templateHTML is coming from in your example...is the src on your image set correctly in that variable? In any case, selecting an image and running this code seems to work fine for me in the demo: editor.getSelected().set("src", "http://via.placeholder.com/350x150")

artfJanuary 18, 2018

@Deepak813 as already mentioned by Ryan you have to use editor.getSelected().set('src',image_Url)

AkibDeraiya123January 9, 2019

@ryandeba @artf Is there any possibilities to change other attributes of image like class, id etc? I had tried with like, But this seems not working in my case. Can you guys please help me how can i change other attributes of this image tag?

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.