Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image-resource

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-resource

Image resource provide a simple way to load images using promises, and patch IE naturalWidth and naturalHeight for SVG.

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Image Resource

Image resource provide a simple way to load images using promises, and patch IE naturalWidth and naturalHeight for SVG.

Example:

ImageResource.load('my-image.svg').then((image) => {
  document.body.append(image.image);
  console.log(image.naturalWidth, image.naturalHeight);
});

Documentation

load(source: string): Promise<ImageResource>;

Load an image from an url. Return a promise resolved when image loading is complete.

addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
dispatchEvent(event: Event): boolean;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;

It's possible to bind events like any other EventTarget.

readonly naturalWidth: number;
readonly naturalHeight: number;

It's possible to read the natural size of the image (working on IE with SVG too).

public image: HTMLImageElement;

Finally, it's possible to acces to the original Image element through imageResource.image

FAQs

Package last updated on 05 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc