Issue #2510πŸ’¬ AnsweredOpened January 15, 2020by simplecommerce3 reactions

How to add link on an image?

Quick answerby simplecommerce❀ 1

Ok, I was able to get it working by doing the following: I don't know if it's a good way or not, appreciate any feedback.

Read full answer below ↓

Question

Hi, quick question.

I have an image and I just want to add a link on it. Using the model, what is the easiest way to add a link on the image?

I tried to use model.replaceWith but the problem is that if I put some styling on the image and then call model.replaceWith, the styles are removed.

Is there a better way to achieve this?

Thanks!

Answers (3)

simplecommerceβ€’ January 16, 2020

Ok, I was able to get it working by doing the following: I don't know if it's a good way or not, appreciate any feedback.

pouyamiralayiβ€’ January 17, 2020

Hi @simplecommerce ! cheers!

simplecommerceβ€’ January 17, 2020

Hi @simplecommerce ! cheers! Hi @pouyamiralayi, thanks for the reply. I didn't mean by creating a new component, what I meant was to simply replace a rendered component model in the canvas (an image) by wrapping it inside a link (a) while keeping the styles. The example code I pasted does exactly t...

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.