2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9 `core-image` is an element for displaying an image that provides useful sizing and
10 preloading options not found on the standard `<img>` tag.
12 The `sizing` option allows the image to be either cropped (`cover`) or
13 letterboxed (`contain`) to fill a fixed user-size placed on the element.
15 The `preload` option prevents the browser from rendering the image until the
16 image is fully loaded. In the interim, either the element's CSS `background-color`
17 can be be used as the placeholder, or the `placeholder` property can be
18 set to a URL (preferably a data-URI, for instant rendering) for an
21 The `fade` option (only valid when `preload` is set) will cause the placeholder
22 image/color to be faded out once the image is rendered.
26 Basically identical to <img src="..."> tag:
28 <core-image src="http://lorempixel.com/400/400"></core-image>
30 Will letterbox the image to fit:
32 <core-image style="width:400px; height:400px;" sizing="contain"
33 src="http://lorempixel.com/600/400"></core-image>
35 Will crop the image to fit:
37 <core-image style="width:400px; height:400px;" sizing="cover"
38 src="http://lorempixel.com/600/400"></core-image>
40 Will show light-gray background until the image loads:
42 <core-image style="width:400px; height:400px; background-color: lightgray;"
43 sizing="cover" preload src="http://lorempixel.com/600/400"></core-image>
45 Will show a base-64 encoded placeholder image until the image loads:
47 <core-image style="width:400px; height:400px;" placeholder="data:image/gif;base64,..."
48 sizing="cover" preload src="http://lorempixel.com/600/400"></core-image>
50 Will fade the light-gray background out once the image is loaded:
52 <core-image style="width:400px; height:400px; background-color: lightgray;"
53 sizing="cover" preload fade src="http://lorempixel.com/600/400"></core-image>
56 @group Polymer Core Elements
59 --><html><head><link rel=
"import" href=
"../polymer/polymer.html">
61 </head><body><polymer-element name=
"core-image" assetpath=
"">
63 <link rel=
"stylesheet" href=
"core-image.css">
64 <template if=
"{{!sizing}}">
67 <template if=
"{{preload && fade}}">
68 <div id=
"placeholder" fit=
""></div>
74 <script src=
"core-image-extracted.js"></script></body></html>