Automattic/jetpack — pull request #499 by rase- (2014-04-26 20:32:18+00:00)
Title: Lazy load and tiled galleries interop and some other enhancements

This PR has some improvements to both the code and functionality of Tiled Galleries along with a few changes in Photon.

* The first and foremost purpose of the PR is to improve the interoperability of lazy loading (via some whatever plugin, e.g., the official Lazy Load plugin) and Tiled Galleries. To get there, some changes had to be made to how the tiles are placed and how their size is reserved. You should find all the information in the commit messages. Important fixes include proper behaviour when refreshing pages (not force refresh) when the official Lazy Load plugin is activated in Firefox, IE and Safari as well as dropping the need to eagerly load Tiled Gallery containers (as is done in the official plugin). To test this out, I created a small lazy load [plugin of my own](https://github.com/rase-/WP-jQuery-Lazy-Load).

* The aforementioned changes also took care of another issue that I reported earlier to happen on Chrome: https://github.com/Automattic/jetpack/issues/476 and would in theory allow for Tiled Galleries to work without Photon as well.

* When you have a four image square layout, sometimes when the one remainder image that doesn't fit the three images per line would be placed on top, and be a few pixels less wide than the three images below it. This is also fixed by properly computing the margin into the remainder space width.

* Interoperability of lazy loading and Photon was also enhanced: images not in a tiled gallery would not be displayed properly when Photon was enabled before.

* A regex in Photon that strips the `height` and `width` attributes from images would strip attributes like `data-original-width` into `data-original-`. This regex now only strips the `height ` and `width` attributes by making sure there is a whitespace before the attribute.

* Resizing looks smoother in browsers without introducing any additional lag (at least in IE10, and a few latest and not so fresh Chrome, FF and Safari versions) by removing the timeout logic in `$( window ).resize`.

What do you think of the changes? Ideas for improvement?