Skip to content

Add and enforce image size attributes for rendered images#7248

Merged
aduth merged 2 commits intomainfrom
aduth-add-enforce-image-size
Oct 28, 2022
Merged

Add and enforce image size attributes for rendered images#7248
aduth merged 2 commits intomainfrom
aduth-add-enforce-image-size

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Oct 28, 2022

🛠 Summary of changes

Adds a linter to enforce that any image_tag includes either width and height or a size attribute, so as to adhere to best practices to avoid layout shifts.

Related resources:

Visually, there should be no effective difference with these changes. This was made somewhat challenging by how some images are scaled, since adding width or height where it was previously not set could create issues where the image was scaled down due to constraints of its parent container. I've done a manual review to try to ensure no regressions in the display of images.

📜 Testing Plan

  • Ensure no regressions in the visual appearance of affected images
  • Ensure lint passes make lint

changelog: Bug Fixes, Images, Improve image rendering to avoid page layout shifts
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, love this!

See: #7248 (comment)
Co-Authored-By: Zach Margolis <zbmargolis@gmail.com>
@aduth aduth force-pushed the aduth-add-enforce-image-size branch from 4f902e3 to dfc7391 Compare October 28, 2022 18:26
Comment on lines +64 to +70
Exclude:
- app/components/barcode_component.html.erb
- app/views/partials/multi_factor_authentication/_mfa_selection.html.erb
- app/views/shared/_nav_branded.html.erb
- app/views/sign_up/completions/show.html.erb
- app/views/users/two_factor_authentication_setup/index.html.erb
- app/views/users/webauthn_setup/new.html.erb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that I'd hoped to have disabled these rules inline at the specific point in the file where the image_tag is called, but it doesn't currently appear to be possible to do with ERBLint.

Upstream issue: Shopify/erb_lint#243

@aduth aduth merged commit 06465c1 into main Oct 28, 2022
@aduth aduth deleted the aduth-add-enforce-image-size branch October 28, 2022 19:37
@aduth aduth mentioned this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants