Image is not resizing after creating a link for image
You're flattening the component by doing this selectedComponent.view.el['outerHTML'] and so you're removing all its properties. Read more about how Components work.
Read full answer below āQuestion
let href = this.getHref();
let title = this.title;
let childHtml =`<a id="${selectedComponent.ccid}" title="${title}" href="${href}" target="_blank" class="gjs-comp-selected">${selectedComponent.view.el['outerHTML']}</a>`;
const coll = selectedComponent.collection;
const at = coll.indexOf(selectedComponent);
coll.remove(selectedComponent);
coll.add(childHtml, { at });
selectedComponent.view.render();```
Answers (1)
You're flattening the component by doing this selectedComponent.view.el['outerHTML'] and so you're removing all its properties.
Read more about how Components work.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2305
Wrap and UnWrap function is not working in Grapesjs selected element
if(data.component.get('tagName') === 'img') { const selectedComponent = editor.getSelected(); const href = this.getHref(); const childHtml...
Issue #1578
[Question] Custom request on "src" attributes
I implemented a small GrapesJS editor that allows to edit Django/Jinja2 templates. GrapesJS by default is trying to GET the image preview o...
Issue #6515
Resizing an element affects all elements with the same class
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 136.0.7103.93 Reproducible demo lin...
Issue #4529
When we resize an image with a class 'xyz', all the elements on the page with same class also gets resized because editor adds css to those classes.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Version 104.0.5112.101 (Official Build) (arm...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins ā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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Tutorial
GrapesJS vs Webflow vs Builder.io vs Puck: Which Visual Builder to Choose in 2026
A practitioner's 2026 comparison of GrapesJS, Webflow, Builder.io, and Puck ā pricing, AI features, lock-in, and a one-line rule for picking the right one
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.