Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
ngx-gravatar
Advanced tools
The gravatar directive for angular 4+. It is AoT compatible.
Live demo here.
Play with ngx-gravatar here on stackblitz.
Install ngx-gravatar
via NPM, using the command below.
npm install --save ngx-gravatar
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 { }
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">
Attribute | Type | Required | Default | Description |
---|---|---|---|---|
email | string | requried | Email associated with Gravatar | |
src | string | optional | Custom image to use | |
preferGravatar | boolean | optional | false | If true , Gravatar will have higher priority. Otherwise, custom image will be loaded first. |
size | number | optional | 40 | Size of the avatar |
round | boolean | optional | true | Circle avatar |
cornerRadius | number | optional | 0 | Round the corner of square avatar. Only applied when round is set to false |
borderColor | string | optional | Specify the color of the border | |
borderWidth | string | optional | Specify the width of the border | |
style | object | optional | Style object that will be applied on the <img> tag | |
fallback | string | optional | retro | The fallback string of Gravatar. Possible values: blank , indenticon , mm , monsterid , retro , robohash , wavatar . |
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 { }
Option | Type | Required | Default | Description |
---|---|---|---|---|
hasBorder | boolean | optional | false | Specify whether to have border or not |
preferGravatar | boolean | optional | false | If true , Gravatar will have higher priority. Otherwise, custom image will be loaded first. |
size | number | optional | 40 | Size of the avatar |
round | boolean | optional | true | Circle avatar |
cornerRadius | number | optional | 0 | Round the corner of square avatar. Only applied when round is set to false |
borderRadius | string | optional | 50% | Only applied when round is set to true. |
borderColor | string | optional | #000000 | Specify the color of the border |
borderWidth | string | optional | 1 | Specify the width of the border |
borderStyle | object | optional | solid | Style object that will be applied on the <img> tag |
fallback | string | optional | retro | The fallback string of Gravatar. Possible values: blank , indenticon , mm , monsterid , retro , robohash , wavatar . |
MIT © t-ho
FAQs
A customizable Gravatar for Angular applications.
The npm package ngx-gravatar receives a total of 1,793 weekly downloads. As such, ngx-gravatar popularity was classified as popular.
We found that ngx-gravatar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.