WPTT / theme-sniffer

Theme Sniffer plugin using sniffs.
MIT License
269 stars 3 forks source link

[New Feature] Discourage CSS rules for images setting width:auto or width:100% #194

Open joyously opened 4 years ago

joyously commented 4 years ago

Apparently, I wrote the issue on the wrong repo, so I'm moving it to here. Flag CSS rules for images that have the property width:auto. There is no rule in the Handbook for this, but it falls under the general guideline to honor the user's choices.

The default value for CSS width is auto, so there is no need to specify it. When it is specified, it will override the HTML width attribute. So an img tag with a different width attribute than the source image is would be affected, and it will display as the size of the source image instead of the size the user requested.

This should also include width:100%. I've seen several of these lately, whether targeting just the widgets or gallery or all of the user content area, it messes up icons and thumbnails or any image less than full width.

Describe the solution you'd like For CSS rules that target img as the last part of the selector, issue a warning when width:auto or width:100% is found. Suggest testing with icons or thumbnails with width attributes.

Additional context Putting more icons or thumbnails into the unit test data might help, but a warning would be better. See comments and examples on the original issue: https://github.com/WPTRT/WPThemeReview/issues/137