judesfernando / initial.js Goto Github PK
View Code? Open in Web Editor NEWSimple jQuery plugin to make Gmail like text avatars for profile pictures
License: MIT License
Simple jQuery plugin to make Gmail like text avatars for profile pictures
License: MIT License
If the element contains the attribute data-name with only numbers the result of unicode_slice is an empty string on v0.2.0, the v0.1.0 throws the error on substring function and stops the iteration.
Based on some tests on casting strings (http://jsben.ch/#/ghQYR) problably the best way to resolve this is casting with '' for better performance.
Line 63:
var c = unicode_slice('' + settings.name, 0, settings.charCount).toUpperCase();
Hello, thank you for that nice feature :)
I tried it but image still not working in internet explorer ( all versions) i dont know why.
is there other settings to add to get it supported by IE please?
thank you so much
this is my code :
<script type="text/javascript">
$(document).ready(function(){
$('.profile-pic').initial({width:46,height:46,fontSize:20,fontWeight:400});
$('.initial-logo').initial({width:80,height:80});
})
</script>
<img class="profile-pic media-object pull-left img-circle" data-name="Joe">
i get ( X ) in the place of image when its IE
Thank you
First of all thankyou so much for the great plugin.
I tried to add custom downloaded font from google font ( Hind Silguri ) and its not updating.
How to implement custom font in the js? I tried to modify the js itself but its not working.
can you please help?
When validates a page using initial js with W3C Validator, appears one error validation in each image:
src="data:image/svg+xml;base6..."
but it's seem it's not valid.π Thank you!
Right now initial.js uses string.substr, which is non-unicode aware.
This means that unicode names (for example, "πΈπππ»") throw an exception. (the result of string.substr
is ""
)
There is unicode-substring for making substrings. Maybe it could be used to calculate the substrings correctly.
At the very least, unicode should not throw an error.
PS: In case it is useful, I also found this polyfill which implements String.prototype.at which is an ECS6 unicode-aware version of charAt
Could you please do:
$ git tag v0.1.0
$ git push -t
On this repo so things like bower and rails-assets can pick the version number?
Thanks!
When updating data-name from one value to another, the Avatar does not refresh to reflect the new value.
Would be nice to have initial.js be fallback for users who have not uploaded profile pic.
Hi,
it seems to me the plugin is designed to give same letter the same color, although it is a different username. I think it's better to make the color dependent on something else than the first letter - same color of two different initials can cause no confusion, but what can cause confusing the users is the same color of the same letter.
I propose (made this for myself as a workaround) changing around line 76
this:
var colorIndex = Math.floor((c.charCodeAt(0) + settings.seed) % colors.length);
to something like this:
var colorIndex = Math.floor((settings.name.charCodeAt(1) + settings.name.charCodeAt(3) + settings.seed) % colors.length);
Hey @judesfernando,
Thanks for a great and nifty plugin. I just released a Rails gem to wrap it up and use it with the Assets Pipeline. I just wanted to let you know.
https://github.com/dgilperez/initialjs-rails
Cheers!
CSS border-radius property cannot be applied to svg images. So the radius option is ignored and the output is always a rectangle.
Is there a way to override the background color using a data attribute?
Hi, just an fyi for anyone looking to use this on their wordpress site.
https://wordpress.org/plugins/echo1-consulting-inital-js-avatar/
if the name is a number, it does work but doesn't add background color
Hi there,
It seems if I try to add a class to the image and set the css to width:25px the image resizes but the text is not centered
I believe it could be an issue with Edge text-anchor="middle"
http://judelicio.us/ seems discontinued.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.