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

ngx-gravatar

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-gravatar

A customizable gravatar for Angular 4+ applications

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm version

ngx-gravatar

The gravatar directive for angular 4+. It is AoT compatible.

Angular Gravatar Directive

Demo

Live demo here.

Play with ngx-gravatar here on stackblitz.

Installation

Install ngx-gravatar via NPM, using the command below.

NPM

npm install --save ngx-gravatar

Getting started

Import the GravatarModule in your root application module AppModule:


import { BrowserModule } from  '@angular/platform-browser';
import { NgModule } from  '@angular/core';

import { AppComponent } from './app.component';

import { GravatarModule } from  'ngx-gravatar';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    // Import GravatarModule
    GravatarModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use in component

After importing the GravatarModule, you can use the ngx-gravatar directive in any components as below:

<img ngx-gravatar [email]="'example@mail.com'">
<img ngx-gravatar [email]="'example@mail.com'" size="30">
<img ngx-gravatar [email]="'example@mail.com'" size="30" src="assets/avatar.jpg">
<img ngx-gravatar [email]="'example@mail.com'" size="30" src="assets/avatar.jpg" [style]="styleObject">

Input Parameters

AttributeTypeRequiredDefaultDescription
emailstringrequriedEmail associated with Gravatar
srcstringoptionalCustom image to use
preferGravatarbooleanoptionalfalseIf true, Gravatar will have higher priority. Otherwise, custom image will be loaded first.
sizenumberoptional40Size of the avatar
roundbooleanoptionaltrueCircle avatar
cornerRadiusnumberoptional0Round the corner of square avatar. Only applied when round is set to false
borderColorstringoptionalSpecify the color of the border
borderWidthstringoptionalSpecify the width of the border
styleobjectoptionalStyle object that will be applied on the <img> tag
fallbackstringoptionalretroThe fallback string of Gravatar. Possible values: blank, indenticon, mm, monsterid, retro, robohash, wavatar.

Override Default Configuration

Default configuration options can be set globally by using the .forRoot() method. Note that the input parameters that are passed into an ngx-gravatar element will override any custom global config options that have been set. Please see below for an example of how to override default configurations.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { GravatarModule, GravatarDefaultConfig, FALLBACK_TYPES } from 'ngx-gravatar';

const gravatarConfig: GravatarDefaultConfig = {
  fallback: FALLBACK_TYPES.monsterid,
  hasBorder: true,
  borderColor: '#00ACC1',
}

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    // Import GravatarModule with custom configuration globally
    GravatarModule.forRoot(gravatarConfig)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Options

OptionTypeRequiredDefaultDescription
hasBorderbooleanoptionalfalseSpecify whether to have border or not
preferGravatarbooleanoptionalfalseIf true, Gravatar will have higher priority. Otherwise, custom image will be loaded first.
sizenumberoptional40Size of the avatar
roundbooleanoptionaltrueCircle avatar
cornerRadiusnumberoptional0Round the corner of square avatar. Only applied when round is set to false
borderRadiusstringoptional50%Only applied when round is set to true.
borderColorstringoptional#000000Specify the color of the border
borderWidthstringoptional1Specify the width of the border
borderStyleobjectoptionalsolidStyle object that will be applied on the <img> tag
fallbackstringoptionalretroThe fallback string of Gravatar. Possible values: blank, indenticon, mm, monsterid, retro, robohash, wavatar.

License

MIT © t-ho

Keywords

FAQs

Package last updated on 03 May 2018

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