How can I create an existing image as link
I've solved in this way: on backend script: var originalImage = editor.DomComponents.getType('image'); editor.DomComponents.addType('image', { model: originalImage.model.extend({ defaults: Object.assign({}, originalImage.model.prototype.defaults, { traits:[{ type: "text", label: "ID", name: "id" }, { type: "text", lab...
Read full answer below βQuestion
I have an existing template that is currently displaying the image in the middle of the page. Now, I want to make it link or clickable so that if the user clicks on the image it should open given href. How can do that? Currently, we have link block and inside of it, we can place an image. But, I'm asking for the reverse - Existing image to link.
Answers (3)
I've solved in this way: on backend script: var originalImage = editor.DomComponents.getType('image'); editor.DomComponents.addType('image', { model: originalImage.model.extend({ defaults: Object.assign({}, originalImage.model.prototype.defaults, { traits:[{ type: "text", label: "ID", name: "id" },...
SEO Friendly backend (added Alt attr) var originalImage = editor.DomComponents.getType('image'); editor.DomComponents.addType('image', { model: originalImage.model.extend({ defaults: Object.assign({}, originalImage.model.prototype.defaults, { traits:[{ type: "text", label: "ID", name: "id" }, { typ...
@chauhankiran the correct step would be to create a custom component, kind of link-image which would replace the image one. The root of this component will be the <a> element and the inner one will be the image.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #935
In creating a custom block how do you create it's corresponding settings?
I want to make a link that will let the user enter the url for it or to let him choose a link to another page which he already created.
Issue #482
Default asset manager in custom component
I am in process to create custom component for below template and we want to have user enter text,link,hover text and select image and want...
Issue #5729
Editing/replacing the text inside of a link
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v122 Reproducible demo link https:/...
Issue #4273
How to trigger the 'Import Template (modal)' on page load
Hello, Please i'm in need of the logic on how to the import template modal on initialization of the page... I'm using the newsletter preset...
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
GrapesJS DevTools: A Developer Panel Inside Your Editor
If you've ever debugged GrapesJS with console.log(editor.getSelected()) and a dozen throwaway event listeners β this post is for you.
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
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins β TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.