Issue #3247πŸ’¬ AnsweredOpened January 24, 2021by fmay1 reactions

Traits

Quick answerby artf❀ 1

Hi Freddy, you can simply extend the image component in this case

Read full answer below ↓

Question

Hi @artf - what you've built is magnificent. It's been a gentle struggle as I'm far from being a JS wizard. However, I've got just about everything fully configured - except for this! I want to set traits that display when an image is selected (alt, src, id). I am sure it can be done once at initialisation, but I'm buggered if I can figure out how do do it. I've read everything I can find in the issues and am still stuck. The only way I got it to work is as follows ... Also - the out-of-the-box "Alt" comes first and I'd really like it to be after . I can't figure out how to get rid of it as d...

Answers (2)

artfβ€’ January 28, 2021

Hi Freddy, you can simply extend the image component in this case

editor.Components.addType('image', {
  model: {
   defaults: {
     traits: [{name: 'alt'}, {name: 'src'}, {name: 'id'}]
   }
  }
});
GJSBlockβ€’ May 17, 2026

Thanks for reporting this, @fmay. Great question about Question : Traits. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can be achieved by listeni...

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.