Issue #2684💬 AnsweredOpened March 25, 2020by imso0770 reactions

Picture element

快速解答by imso077

Hi, hi you all solve the problem of responsive images ? (We have to change images, because of the content of the image should change on smaller devices, so the focus is smaller)

Read full answer below ↓

Question

Hi, I would like to add a "picture" block to the editor, where we could define differnt image for different device, the base html for that would look like so:

<picture>
        <source data-gjs-type="source" media="(min-width: 650px)" srcset="">
        <source data-gjs-type="source" media="(min-width: 465px)" srcset="">
        <img src="">
      </picture>

My problem is, wen it is inserted to the editor, the img component, is viisble, and moveable, even from the picture element. With that it could be cause unintended layout problems, and the images could end up in different place. Another issue with this, that the amount of sources could be changing by usage, sometimes, it is only 1 source (device support) reuired sometimes, 3...

What would be the best way to overcome these problem?

Answers (2)

imso077March 30, 2020

Hi, hi you all solve the problem of responsive images ? (We have to change images, because of the content of the image should change on smaller devices, so the focus is smaller)

artfApril 2, 2020

Learn how to create custom Components and then take a look at all the available properties on the Component (so you can tell, for example, the image not being draggable)

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.