PolymerElements/iron-image

Name: iron-image

Owner: PolymerElements

Description: Image element with sizing and preloading options

Created: 2015-04-16 17:38:51.0

Updated: 2018-04-16 18:15:49.0

Pushed: 2018-05-23 02:29:54.0

Homepage: https://www.webcomponents.org/element/PolymerElements/iron-image

Size: 177

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build status

Demo and API docs

<iron-image>

iron-image is an element for displaying an image that provides useful sizing and preloading options not found on the standard <img> 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 <img src="..."> tag:

n-image src="http://lorempixel.com/400/400"></iron-image>

Will letterbox the image to fit:

n-image style="width:400px; height:400px;" sizing="contain"
c="http://lorempixel.com/600/400"></iron-image>

Will crop the image to fit:

n-image style="width:400px; height:400px;" sizing="cover"
c="http://lorempixel.com/600/400"></iron-image>

Will show light-gray background until the image loads:

n-image style="width:400px; height:400px; background-color: lightgray;"
zing="cover" preload src="http://lorempixel.com/600/400"></iron-image>

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

n-image style="width:400px; height:400px;" placeholder="data:image/gif;base64,..."
zing="cover" preload src="http://lorempixel.com/600/400"></iron-image>

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

n-image style="width:400px; height:400px; background-color: lightgray;"
zing="cover" preload fade src="http://lorempixel.com/600/400"></iron-image>

| 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 |


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.