You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
Is your feature request related to a problem? Please describe.
I would love to see a srcset attribute on the AB Container block's background image, in the interest of improving page load speed on mobile devices, performance scores, etc.
Describe the solution you'd like
Adding a wp-image-[ID] class to the img tag would trigger Wordpress to add the srcset automatically (see WordPress/gutenberg#8593). I forked AB and tried adding the class name on line 232 of /src/blocks/block-contained/index.js. It is tested and working as below:
Additional context
When I tried adding the same code to line 155 in order to create the same container markup in the editor, Gutenberg threw an error about invalid syntax in the block. It wanted to wrap the image in <figure> tags. I don't know that much about Gutenberg coding and don't know if it's best practice to keep editor and front-end markup exactly the same. But the above change does trigger WP to create the srcset.
Please let me know if you want me to submit a PR for this.
Thanks!
The text was updated successfully, but these errors were encountered:
@mindctrl I just read some of their docs on this and understand the purpose, but I wouldn't trust myself to code it yet. I'll take a closer look. If one of you more Gutenberg-knowledgable folks gets to it first, don't wait for me. 😄
Is your feature request related to a problem? Please describe.
I would love to see a
srcset
attribute on the AB Container block's background image, in the interest of improving page load speed on mobile devices, performance scores, etc.Describe the solution you'd like
Adding a
wp-image-[ID]
class to the img tag would trigger Wordpress to add the srcset automatically (see WordPress/gutenberg#8593). I forked AB and tried adding the class name on line 232 of /src/blocks/block-contained/index.js. It is tested and working as below:Additional context
When I tried adding the same code to line 155 in order to create the same container markup in the editor, Gutenberg threw an error about invalid syntax in the block. It wanted to wrap the image in
<figure>
tags. I don't know that much about Gutenberg coding and don't know if it's best practice to keep editor and front-end markup exactly the same. But the above change does trigger WP to create the srcset.Please let me know if you want me to submit a PR for this.
Thanks!
The text was updated successfully, but these errors were encountered: