Skip to content

How to replace srcset ? #6201

Answered by mohamedsalem401
asimex asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, sorry for late response.
Please try the following snippit

editor.on('component:update:src', (component) => {
  if (component.get('tagName') !== 'img') return
  component.addAttributes({ 'srcset': component.getAttributes().src })
});

If you want to set the srcset after loading the component, just add

editor.on('component:mount', (component) => {
  if (component.get('tagName') !== 'img') return
  component.addAttributes({ 'srcset': component.getAttributes().src })
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@asimex
Comment options

Answer selected by asimex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants