LetterPic converts usernames into canvas based avatar pictures.
View it on github: jQuery LetterPic github page.
Define html-element with user name in title="John Doe"
attribute.
Then call .letterpic() on proper selector or image with your jquery selector.
title="Jon Snow"
. So it's looks same too.
data-userid=YourInternalUserId
attribute to element.data-userid="1"
value.
You could use letterpic to replace images with broken sources.
Don't forget to place user name to img title
attribute.
src="brokenImageUrl.jpg"
attribute.
By default letterpic uses gradients as background. It has 19 predefined gradient color scheme,
based on google material colors. You can change this scheme, just pass gradients
to options on init.
$(".letterpic").letterpic();
$(".letterpic").letterpic({
gradients: [
["#fff", "#333", "#000", "#777"],
["#aaafff", "#aaa777"],
["#dddfff", "#ddd333", "#ddd777"],
]
});
If you want to use solid color as background, you show pass fill: 'color'
parameter as option on init.
By default letterpic has predefined color scheme with 19 colors, based on google material styles.
You can change this scheme, just pass array of colors: ["#color1", "#color2", ...]
to options on init.
$(".letterpic").letterpic({ fill: 'color' });
$(".letterpic").letterpic({
fill: 'color',
colors: [ "#111", "#222", "#333", "#444", "#555" ]
});
Another possibility is to use image with fill: 'image'
parameter as option on init.
By default letterpic has few example background pattens from colourlovers.com.
You can change this scheme, just pass array of image: ["imageUrl1", "imageUrl2", ...]
to options on init.
Try to define custom fontColor: "#color"
and imageOverlayColor: "#rgbaColor"
to increase the contrast of final image.
$(".letterpic").letterpic({ fill: 'image' });
$(".letterpic").letterpic({
fill: 'image',
images: [
"https://image.freepik.com/free-vector/floral-background-with-watercolor-leaves_1085-886.jpg",
"https://image.freepik.com/free-vector/watercolor-feathers-background_23-2147607455.jpg",
"https://image.freepik.com/free-vector/octopus-pattern-design_1235-151.jpg"
],
fontColor: "#CCC",
imageOverlayColor: "rgba(0, 0, 0, .5)"
});
Option | Default value | Possible values | Description |
---|---|---|---|
fill | 'gradient' | 'color', 'gradient' or 'image' | Background drawing style. |
colors | Array of 19 predifined colors. | Array of colors: ["#453445", "#546343", ...] | Color scheme for color background. It works only if 'fill': 'color' passed to options. |
gradients | Array of 19 predifined gradients. | Array of array of colors: [["#111", "#222", ...], [["#444", "#555", "#000", ...], [["#453445", "#546343"], ...] |
Color scheme for gradient background. It works only if no 'fill' or 'fill': 'gradient' passed to options. |
images | Array of 8 predifined images. | Array of image urls: ["http://url1", "/images/img2", ...] | Image array for image background. It works only if 'fill': 'image' passed to options. |
imageOverlayColor | Transparent. | RGBa color with transparency, e.g. 'rgba(0,0,0,.5))' | Overlay color for 'fill': 'image'. Use it to increase the contrast of avatar. |
font | 'Arial' | Font family name, e.g. 'Arial', 'Verdana', 'Tahomf' | Font family for avatar text. |
fontColor | '#fff' | String with color, e.g. '#fff', '#000' and etc. | Font color for avatar text. |
fontSize | .45 | Relative size of font, any decimal in range from 0 to 1 | Relative size of font for avatar text |