Image is not resizing after creating a link for image
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
BUG: 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 #2356
Add link on image in grapsjs editor
Hi, Add link (href) to image in grapesjs . First we add image in grapesjs and then add link to that image, its shows " Link " text next to...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.