README

[![Build status](https://travis-ci.org/PolymerElements/iron-image.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-image)

_[Demo and API docs](https://elements.polymer-project.org/elements/iron-image)_

##<iron-image>

`iron-image` is an element for displaying an image that provides useful sizing and preloading options not found on the standard `` tag.

The `sizing` option allows the image to be either cropped (`cover`) or letterboxed (`contain`) to fill a fixed user-size placed on the element.

The `preload` option prevents the browser from rendering the image until the image is fully loaded. In the interim, either the element's CSS `background-color` can be be used as the placeholder, or the `placeholder` property can be set to a URL (preferably a data-URI, for instant rendering) for an placeholder image.

The `fade` option (only valid when `preload` is set) will cause the placeholder image/color to be faded out once the image is rendered.

Examples:

Basically identical to `` tag:

```html ```

Will letterbox the image to fit:

```html ```

Will crop the image to fit:

```html ```

Will show light-gray background until the image loads:

```html ```

Will show a base-64 encoded placeholder image until the image loads:

```html ```

Will fade the light-gray background out once the image is loaded:

```html ```

| Custom property | Description | Default | | --- | --- | --- | | `--iron-image-placeholder` | Mixin applied to #placeholder | `{}` | | `--iron-image-width` | Sets the width of the wrapped image | `auto` | | `--iron-image-height` | Sets the height of the wrapped image | `auto` |

Back to blog

Leave a comment