npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-default-image

v0.2.12

Published

Angular library which provides a way prevend image rendering when the image loading failed with custom replacement image and provide extracted meta info from the image.

Downloads

94

Readme

ngx-default-image (latest)

ngx-default-image npm version ngx-default-image

  • Angular library which provides a way prevend image rendering when the image loading failed with custom replacement image.

  • Get extracted meta info from the image.




Import

Import the module on your app.module.ts file as follow.

import { NgxDefaultImageModule} from "ngx-default-image";

Add to imports

imports: [
  ...
  NgxDefaultImageModule
  ...
],

Using META interface

import { META } from "ngx-default-image";

Core function

<img src="'https://dummyimage.com/600x400/fff/000'" 
[imageURL]="imageURL" NgxDefaultImage />
  • imageURL : Replacement image URL (Usually from asset folder in any dimension).

Using service

Emit the function in order to get meta info as follows.

<img src="'https://dummyimage.com/600x400/fff/000'" 
[imageURL]="imageURL" (imageMetaInfo)="imageMetaInfo($event)" 
NgxDefaultImage />
import { META } from "ngx-default-image";
public imageMeta: META;
public imageURL = "https://cdn-icons-png.flaticon.com/128/1829/1829412.png"; // Fallback URL
public imageMetaInfo(event: META) {
  this.imageMeta = event;
  consoloe.log(this.imageMeta);
}

For series of image under loop

<div *ngFor="let img of images:let index = index;">
  <img src="'https://dummyimage.com/600x400/fff/000'" 
  [imageURL]="imageURL" 
  (imageMetaInfo)="imageMetaInfo($event, index)" 
  NgxDefaultImage />
</div>
public imageMetaInfo(event: META, index: number) {
  consoloe.log(`Meta info of image at ${index} is ${event}.`);
}

Ability

The image will return the meta info as follows:

public imageMetaInfo(event: META) {
  this.imageMeta = event;
}

Meta properties

| Properties | Data Type | --------------------|------------- | isValidImage | Boolean | | aspectRatio | string | | x | number | | y | number | | rwidth | number | | rheight | number | | renderTime | string | | top | number | | right | number | | bottom | number | | left | number | | datedOn | any | | width | number | | height | number | | src | string | | esrc | string | | alt | string | | crossorigin | string |

Code integration

To use this package as a service npm i ngx-default-image install this on the root angular project .

Note: Don't forget to run this commend npm i ngx-default-image on root folder or else it will throw error.

Then import the module as follow on imports array

NgxDefaultImageModule