Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add width and height attributes for images added from URL #49

Closed
adamsilverstein opened this issue Dec 14, 2021 · 3 comments
Closed

Add width and height attributes for images added from URL #49

adamsilverstein opened this issue Dec 14, 2021 · 3 comments
Labels
Gutenberg Plugin Issue relates to work on Gutenberg only [Type] Feature A new feature within an existing module

Comments

@adamsilverstein
Copy link
Member

When images are inserted from a URL in the block editor, the resulting HTML should include the image width and height in order to avoid layout shift. Currently it does not.

See WordPress/gutenberg#6652

Fix might need to be in Gutenberg, adding this ticket here since it can impact image performance.

@adamsilverstein adamsilverstein added [Type] Feature A new feature within an existing module [Focus] Images Good First Issue Issue particularly suitable to be worked on by new contributors labels Dec 14, 2021
@westonruter
Copy link
Member

Seems like this would be straightforward to add in Gutenberg when a remote image is added. Once the image is loaded, the width/height can then be persisted as attributes.

Nevertheless, what if the author is linking to an image without consistent width/height? For example, they could be linking to https://source.unsplash.com/random so that a random image with random dimensions are used. If the dimensions were obtained and stored, then this would break. One may say this authors shouldn't be doing this, but alas, it's something users may indeed do (and have a need to do so).

@joemcgill
Copy link
Member

This is not totally fixed, but I don't think we have any follow-up to do that needs tracking here. WordPress adds h/w values to images via wp_img_tag_add_width_and_height_attr() which runs in wp_filter_content_tags(). There are still some edge cases, like images not hosted on the site, which would benefit from adding these via the block markup itself, but I'm unsure how high a priority this should be.

Closing for now as no additional work is planned.

@westonruter
Copy link
Member

Also closely related to #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Plugin Issue relates to work on Gutenberg only [Type] Feature A new feature within an existing module
5 participants