Implement LESS image embedding
authorOri Livneh <ori@wikimedia.org>
Thu, 19 Sep 2013 23:43:46 +0000 (16:43 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 23 Sep 2013 19:59:05 +0000 (19:59 +0000)
commit028f9d8375dea76d90dcd7e6f49ce6ee1a756fa2
treeacaa8f44258501cd35f0c72594cdda3bf5fa1467
parentb67b9e1b488f564b2d3337bef4e90cce8a297ca5
Implement LESS image embedding

This patch adds two custom LESS functions: embeddable() and embed(). Both
functions take a single image file reference as their sole argument.

- embeddable() is a predicate function (= returns a LESS boolean value) that
  checks whether an image is suitable for embedding. An image is suitable if it
  exists, has an appropriate MIME type, and is not too large.
- embed() generates a CSS url() value that contains the reference image encoded
  as a data URI.

The existence of the predicate function allows embeddable() to be used as a
mixin guard. This provides an elegant means of generating a single rule when
the image is not embeddable and multiple rules (the data URI & fallback) when
it is. This technique is used to implement a .background-image mixin, included
in this patch.

Change-Id: I3e06b6d6e8630b7923fa42b3daf1ced3e656bbe7
includes/DefaultSettings.php
resources/mediawiki.less/mediawiki.mixins.less