block editor - Add width & height attributes to Gutenberg’s image output?

admin2025-01-08  3

Images inserted via Gutenberg don't have width & height attribute by default. I'd like to use those for lazy-loading purposes so image is positioned correctly.

Is there a hook or something to add width and height to output? Or should one extend the core block for this?

Images inserted via Gutenberg don't have width & height attribute by default. I'd like to use those for lazy-loading purposes so image is positioned correctly.

Is there a hook or something to add width and height to output? Or should one extend the core block for this?

Share Improve this question asked Dec 12, 2018 at 14:20 RunnickRunnick 1,0293 gold badges14 silver badges26 bronze badges 2
  • isn't there a lazyload JS plugin doens't need width or height attributes? or isn't this an option? – André Kelling Commented Dec 12, 2018 at 15:07
  • @AndréKelling not sure about the other plugins, I'm building my own solution. Also before Gutenberg editor width and height were present on every image by default – Runnick Commented Dec 12, 2018 at 15:39
Add a comment  | 

1 Answer 1

Reset to default 0

If affordable i would rather switch to a lazyload technique without the need of width and height attributes on images over somehow hacking of the editors image output.

This saves you maintenance problems that may occur in the future with Gutenberg Editor.

i do made good experiences with this plugin https://appelsiini.net/projects/lazyload/

edit:

i'm wrong with my assumption. you would need to edit the image output for another plugin anyway. like for my suggested one with data-src to an image.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266021a1087.html

最新回复(0)