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
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
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps β a beginner-friendly 2026 comparison
Tutorial
Lighthouse for GrapesJS: Audit Accessibility and SEO Without Leaving the Editor
Live WCAG 2.1/2.2 accessibility auditor + SEO manager for GrapesJS. Every finding is bound to the exact component β click to select, then one-click fix.
Tutorial
Building an AI-Assisted Document Engine with Next.js, GrapesJS, and the AI SDK
Transform your static template editor into an intelligent, generative design workspace with Vercel AI SDK, AI Elements and Next.js.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.