This feature is a natural-pairing to #620108: Download all remote images locally (a hotlinking solution). If we're going to be doing things like modifying images that aren't resized at all, we should leverage the fact that we already collect the height and width for all images within a post. This patch makes it so that all images, resized or not, get height and width attributes automatically inserted if they are missing.
Adding in height and width helps the page render more quickly, since the image doesn't need to be loaded for the browser to figure out what size it should leave for other HTML to wrap around it. This issue has been brought up in the Insert module queue a couple of times when dealing with ImageCache sizes (which are unpredictable):
#549966: Remove Width and Height attributes when using Image Cache preset
#505420: Calculate width and height attributes when inserting ImageCache images
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | image_resize_filter_add_width_height2.patch | 1.56 KB | quicksketch |
| image_resize_filter_add_height_width.patch | 5.43 KB | quicksketch |
Comments
Comment #1
quicksketchCommitted.
Comment #2
geerlingguy commentedThis is in dev, I take it? If so, do you have a timeline for a new release? If it will be a while, I'll switch to a CVS checkout.
Comment #3
quicksketchI just made the 1.7 release. ;-)
Comment #4
jdanthinne commentedSince the 1.7 update, width and height attributes are duplicated (two times in the same img tag).
This breaks W3C validation.
Comment #5
geerlingguy commented@ jdanthinne - could you provide a sample of the before and after, so quicksketch can see if there might be something missing in his regex to add the tags?
Comment #6
quicksketchShoot, no need to post HTML input/output. I was doing my testing by checking the source in Firebug, which unfortunately "cleans up" the duplicate tags so I wasn't seeing them.
Some examples:
Outputs:
Comment #7
bryancasler commentedI'm very excited this has been added, upgrading now. Can anyone confirm #4?
Comment #8
bryancasler commentedMaybe I'll wait until this evening until this gets hashed out.
Comment #9
quicksketchOkay, sorry for the trouble folks. The current release "works" fine but it's definitely outputting extra height/width attributes on all img tags. I've tested this pretty thoroughly, but if I can get confirmation that this patch corrects the double-attributes problem I'll commit it and make another release.
Comment #10
geerlingguy commentedI've tested the patch on http://archstl.org/ and http://www.lifeisaprayer.com/, and it worked successfully in both cases. I'd say it's safe to commit!
Comment #11
geerlingguy commentedUpdating version.
Comment #12
quicksketchExcellent, thanks geerlingguy. I've committed and made the 1.8 version.
Comment #13
bryancasler commentedI can also confirm this works. I just had to move Image Resize Filter to fire before HTML Purifier.