OLD | NEW |
(Empty) | |
| 1 iron-image |
| 2 ========== |
| 3 |
| 4 `iron-image` is an element for displaying an image that provides useful sizing a
nd |
| 5 preloading options not found on the standard `<img>` tag. |
| 6 |
| 7 The `sizing` option allows the image to be either cropped (`cover`) or |
| 8 letterboxed (`contain`) to fill a fixed user-size placed on the element. |
| 9 |
| 10 The `preload` option prevents the browser from rendering the image until the |
| 11 image is fully loaded. In the interim, either the element's CSS `background-col
or` |
| 12 can be be used as the placeholder, or the `placeholder` property can be |
| 13 set to a URL (preferably a data-URI, for instant rendering) for an |
| 14 placeholder image. |
| 15 |
| 16 The `fade` option (only valid when `preload` is set) will cause the placeholder |
| 17 image/color to be faded out once the image is rendered. |
| 18 |
| 19 Examples: |
| 20 |
| 21 Basically identical to `<img src="...">` tag: |
| 22 |
| 23 ```html |
| 24 <iron-image src="http://lorempixel.com/400/400"></iron-image> |
| 25 ``` |
| 26 |
| 27 Will letterbox the image to fit: |
| 28 |
| 29 ```html |
| 30 <iron-image style="width:400px; height:400px;" sizing="contain" |
| 31 src="http://lorempixel.com/600/400"></iron-image> |
| 32 ``` |
| 33 |
| 34 Will crop the image to fit: |
| 35 |
| 36 ```html |
| 37 <iron-image style="width:400px; height:400px;" sizing="cover" |
| 38 src="http://lorempixel.com/600/400"></iron-image> |
| 39 ``` |
| 40 |
| 41 Will show light-gray background until the image loads: |
| 42 |
| 43 ```html |
| 44 <iron-image style="width:400px; height:400px; background-color: lightgray;" |
| 45 sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image> |
| 46 ``` |
| 47 |
| 48 Will show a base-64 encoded placeholder image until the image loads: |
| 49 |
| 50 ```html |
| 51 <iron-image style="width:400px; height:400px;" placeholder="data:image/gif;base6
4,..." |
| 52 sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image> |
| 53 ``` |
| 54 |
| 55 Will fade the light-gray background out once the image is loaded: |
| 56 |
| 57 ```html |
| 58 <iron-image style="width:400px; height:400px; background-color: lightgray;" |
| 59 sizing="cover" preload fade src="http://lorempixel.com/600/400"></iron-image> |
| 60 ``` |
OLD | NEW |