Socket
Socket
Sign inDemoInstall

ng-fallimg

Package Overview
Dependencies
5
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ng-fallimg

Set a default image when the main source on the image tag doesn't work


Version published
Weekly downloads
42
increased by13.51%
Maintainers
1
Install size
93.5 kB
Created
Weekly downloads
 

Readme

Source

ng-fallimg

Set a default image when the main source on the image tag doesn't work

Installation

$ npm install ng-fallimg --save

Usage

import the NgFallimgModule module and use the static forRoot method in the root module (The forRoot method must be used in the root module), in other modules you only need to import NgFallimgModule without using the forRoot method to use the fallimg directive. Pass an object with the resources that you need.

Note: The default property is required, the forRoot method requires at least an object with a default property.

import { NgFallimgModule } from 'ng-fallimg';

@NgModule({
  ...

  imports: [
    BrowserModule,
    NgFallimgModule.forRoot({
      default: 'https://domain.com/mypicture.png',
      picture1:  'assets/mypicture.png',
      picture2: 'data:image/jpeg;base64, ... ',
    })
  ],

  ...
})
export class AppModule { }

The object to pass to the forRoot method supports: local URLs, external URLs and base64.

once imported the NgFallimgModule module, you can use the fallimg directive on the img tags:

    <img width="100px" src="http://domain.com/the/image/fails" fallimg>

When the main image (defined in the src property) fails and the fallimg property doesn't have a value, it gets the default resource ('https://domain.com/mypicture.png') defined in the object passed in the forRoot method

you can select the resource to load when the main image fails, defining the property's name:

    <img width="100px" src="http://domain.com/the/image/fails" fallimg="picture1">

Now, when the main image fails, picture1 will be loaded ('assets/mypicture.png').

Issues

https://github.com/Lugriz/ng-fallimg/issues

Contributing

Clone the repository

https://github.com/Lugriz/ng-fallimg

install the dependencies

$ npm install

run the test to the library

$ npm run test:lib

Modify the library

Enter to projects/ng-fallimg/src/lib and modify the library

Build the library

$ npm run build:lib

testing before of pull request

Go to app.component.html and test your changes

Keywords

FAQs

Last updated on 02 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc