Clean up image handling

* Refactor the 500+line mess that was renderFile into separate methods

** Build opts object instead of a random collection of variables and backups
   of those variables

* Implement / fix upright option handling

* Add tests for upright.

* Fix the default thumb size to actually be the same as configured in WMF
  wikis. Don't download all thumbs again in a slightly different size when
  switching to VE.

* Fixed a bug that caused serialized tokens to end up in data-parsoid.

TODO:
* Clean up data-parsoid data structures. Most options are now shadowed with
  the corresponding HTML attributes, so we are mostly interested in the order
  of things. An array of normalized option names would be more compact than
  the current array of objects.

* Maybe use upright instead of pixel sizes for thumb and frameless images so
  that they can scale relative to the user pref size.

* Think through if sizes differing from the default is enough indication that
  upright scaling applies when default size is set. Need this info to
  implement the image size pref client-side.

Change-Id: I1f7d31b7bd7c19ad77a7237a92d7961a64a1e3ae
Merge "Clean up image handling"