Page MenuHomePhabricator

Make the defs for image formatting according to viewport from client hints
Open, Needs TriagePublic

Description

The viewport form Client Hints can be used for creating an image that is full-width. This will usually work better than a large thumb or any other fixed-width solution. The image would then be center-aligned but otherwise similar to a thumb. Some of the borders should probably be removed, as at least the outher border does not make sense for a full-width image.

For now this is only implemented in Chrome 46 and later, but it can be expected to be implemented in the remaining browsers in short time.

A fallback would be to set a cookie if the value is not provided, possibly through a redirect on a special page (that is redirect through the page if the hint is missing, then redirect to the original request), or by overriding the original file request from the page itself and at the same time setting the cookie. Redirect through a special page is approx the same as don for entity lookup in Wikidata. The calculated image sizes should be mapped to a limited number of sizes to limit cache fragmentation.

It is perhaps not obvious, but the client hints (or the cookie) can be used for a rewrite operation in the Varnish cache. An alternate approach is to do a rewrite inline in the html code, and then only load a fixed size image for those that has turned off scripting.