1.7.9 • Published 6 years ago

@pearlbea/better-img v1.7.9

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Published on webcomponents.org

better-img

A vanilla component that adds a fallback url and logging function to an image.

Installation

Install the npm package or add the script from unkpg to your HTML page. If you want to use this component in browsers that do not support Custom Elements v1, use the webcomponentsjs polyfill.

Example:

<!-- load the polyfill, if necessary -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.0.0/webcomponents-bundle.js"></script>

<!-- then load the element from unkpg -->
<script src="https://unpkg.com/@pearlbea/better-img@1.4.0/src/better-img/better-img.min.js"></script>

<!-- or from node modules -->
<script src="../node_modules/@pearlbea/better-img/src/better-img/better-img.min.js"></script>

<!-- use the component on your page -->
<better-img
  url="https://placeimg.com/480/640/animals"
  fallback="https://lorempixel.com/480/640"
  alt="an adorable animal">
</better-img>

Usage

propertytypedefaultdescription
url (required)stringnullAn image url. This will become the image's "src" attribute.
fallbackstringnullAn image url. If the url provided returns an error, the fallback url will be assigned to the "src" attribute.
widthnumber480Image width
heightnumber640Image height
altstring""Image alt text
logstringnullIf you provide the name of a function, it will be called if the url returns an error and receive the error object as a parameter.

Running the tests

To setup the testing tools:

npm install

Then to run the tests:

npm test

Tests use web-component-tester, which does not work on Node 10. See the web-component-tester docs for more info.

Viewing your component

npm start

License

MIT

1.7.9

6 years ago

1.7.5

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.9

6 years ago

1.2.3

6 years ago

1.2.1

6 years ago