Home | History | Annotate | Download | only in iron-image
      1 
      2 <!---
      3 
      4 This README is automatically generated from the comments in these files:
      5 iron-image.html
      6 
      7 Edit those files, and our readme bot will duplicate them over here!
      8 Edit this file, and the bot will squash your changes :)
      9 
     10 The bot does some handling of markdown. Please file a bug if it does the wrong
     11 thing! https://github.com/PolymerLabs/tedium/issues
     12 
     13 -->
     14 
     15 [![Build status](https://travis-ci.org/PolymerElements/iron-image.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-image)
     16 
     17 _[Demo and API docs](https://elements.polymer-project.org/elements/iron-image)_
     18 
     19 
     20 ##&lt;iron-image&gt;
     21 
     22 `iron-image` is an element for displaying an image that provides useful sizing and
     23 preloading options not found on the standard `<img>` tag.
     24 
     25 The `sizing` option allows the image to be either cropped (`cover`) or
     26 letterboxed (`contain`) to fill a fixed user-size placed on the element.
     27 
     28 The `preload` option prevents the browser from rendering the image until the
     29 image is fully loaded.  In the interim, either the element's CSS `background-color`
     30 can be be used as the placeholder, or the `placeholder` property can be
     31 set to a URL (preferably a data-URI, for instant rendering) for an
     32 placeholder image.
     33 
     34 The `fade` option (only valid when `preload` is set) will cause the placeholder
     35 image/color to be faded out once the image is rendered.
     36 
     37 Examples:
     38 
     39   Basically identical to `<img src="...">` tag:
     40 
     41 ```html
     42 <iron-image src="http://lorempixel.com/400/400"></iron-image>
     43 ```
     44 
     45   Will letterbox the image to fit:
     46 
     47 ```html
     48 <iron-image style="width:400px; height:400px;" sizing="contain"
     49   src="http://lorempixel.com/600/400"></iron-image>
     50 ```
     51 
     52   Will crop the image to fit:
     53 
     54 ```html
     55 <iron-image style="width:400px; height:400px;" sizing="cover"
     56   src="http://lorempixel.com/600/400"></iron-image>
     57 ```
     58 
     59   Will show light-gray background until the image loads:
     60 
     61 ```html
     62 <iron-image style="width:400px; height:400px; background-color: lightgray;"
     63   sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image>
     64 ```
     65 
     66   Will show a base-64 encoded placeholder image until the image loads:
     67 
     68 ```html
     69 <iron-image style="width:400px; height:400px;" placeholder="data:image/gif;base64,..."
     70   sizing="cover" preload src="http://lorempixel.com/600/400"></iron-image>
     71 ```
     72 
     73   Will fade the light-gray background out once the image is loaded:
     74 
     75 ```html
     76 <iron-image style="width:400px; height:400px; background-color: lightgray;"
     77   sizing="cover" preload fade src="http://lorempixel.com/600/400"></iron-image>
     78 ```
     79 
     80 | Custom property | Description | Default |
     81 | --- | --- | --- |
     82 | `--iron-image-placeholder` | Mixin applied to #placeholder | `{}` |
     83 | `--iron-image-width` | Sets the width of the wrapped image | `auto` |
     84 | `--iron-image-height` | Sets the height of the wrapped image | `auto` |
     85 
     86 
     87