Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
avatar-initials
Advanced tools
JavaScript library for showing Gravatars or generating user avatars from initials.
Avatar is a JavaScript library for showing Gravatars or generating user avatars.
There are several examples on the website.
import Avatar from 'avatar-initials';
const avatar = new Avatar(document.getElementById('avatar'), {
'useGravatar': false,
'initials': 'MC',
});
This example will render an avatar with my initials "MC" as the image.
Avatar is highly customizable and most options are self explanatory:
useGravatar: true # Allow Gravatars or not.
fallbackImage: '' # URL or Data URI used when no initials are provided and not using Gravatars.
size: 80 # Size in pixels, fallback for hidden images and Gravatar
# Initial Avatars Specific
initials: '' # Initials to be used.
initial_fg: '#888888' # Text Color
initial_bg: '#f4f6f7' # Background Color
initial_size: null # Text Size in pixels
initial_weight: 100
initial_font_family: "'Lato', 'Lato-Regular', 'Helvetica Neue'"
# Gravatar Specific
hash: null # Precalculated MD5 string of an email address
email: null # Email used for the Gravatar
fallback: 'mm' # Fallback Type
rating: 'x' # Gravatar Rating
forcedefault: false # Force Gravatar Defaults
allowGravatarFallback: false # Use Gravatars fallback, not fallbackImage
# GitHub Specific
github_id: null # GitHub User ID.
# Avatars.io Specific
use_avatars_io: false # Enable Avatars.io Support
avatars_io:
user_id: null # Avatars.io User ID
identifier: null # Avatars.io Avatar Identifier
twitter: null # Twitter ID or Username
facebook: null # Facebook ID or Username
instagram: null # Instagram ID or Username
size: 'medium' # Size: small, medium, large
npm install --save avatar-initials
or
<script src="md5.js"></script>
<script src="avatar.js"></script>
Avatar expects a window.md5()
function to be defined in order to generate the hashes needed for Gravatar.
I haven't used jQuery in a long time and don't need it personally, so if you still use it the old helper is below.
if (typeof jQuery !== 'undefined') {
jQuery.fn.avatar = function avatar(options) {
return this.each(() => {
/* istanbul ignore else */
if (!jQuery.data(this, 'plugin_avatar')) {
jQuery.data(this, 'plugin_avatar', new Avatar(this, options));
}
});
};
}
To execute all unit tests, open test/index.html
in your target browser.
If you used any version less than 3 and still need to use it, you can stick to v2.6.0 or use the new build/avatar.browser.js
build. If you are using Webpack or similar the npm version should work fine.
These are the browsers I have tested on personally:
Pretty styles and design support kindly provided by Andrew Crocker. Built with love at Apptentive.
There are a lot of these and keeping up with them is hard, so here's a list:
package.json
Avatar is MIT licensed.
3.0.2 (April 2nd, 2018)
FAQs
JavaScript library for showing Gravatars or generating user avatars from initials.
The npm package avatar-initials receives a total of 800 weekly downloads. As such, avatar-initials popularity was classified as not popular.
We found that avatar-initials 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.