mdeering / gravatar_image_tag Goto Github PK
View Code? Open in Web Editor NEWA configurable and documented Rails view helper for adding gravatars into your Rails application
License: MIT License
A configurable and documented Rails view helper for adding gravatars into your Rails application
License: MIT License
The url_params
function joins the bits with &
, which results in double-encoding if you attempt to use the results of gravatar_url
anywhere; it should just produce a clean URL and let Rails do its own escaping as appropriate.
I would like to have the width
and height
attributes set in most cases, but be able to override this behavior in some cases, when I am using the tag in a responsive situation.
Is there any reason that this is looking into the configuration directly, instead of looking into the provided options
? Or am I not reading this right?
How do I add more options (such as class or id) to the helper call?
I have a hash options
with the attributes I want to add
I tried gravatar_image_tag(email, options)
I tried gravatar_image_tag(email, :options => options)
I tried gravatar_image_tag(email, :gravatar => { .. }.merge(option))
none work..
Following Ruby on Rails Tutorial Learn Rails by Example,
i get this message using rails 3.0.1 and gravatar_image_tag 0.1.0. Any idea?
Since browsers layout web pages faster when they don't have to wait for an image (or fifty) to come down the net pipe, and gravatar_image_tag always knows what sizes they will be, could you add the corresponding width/height attributes to the img tag, too?
Thanks!
took me a while to figure out why gravatar_image_url
wasn't working
Hi, I'm not sure if you are supporting this gem anymore but if you are is there any change you can take a look at it for Ruby 3, specifically the keyword arguments breaking change?
As asked on stackoverflow, I'm having issues when mixing 2 config options: having an external default image and resizing it. Using v1.0.0, here is my scenario:
http://www.iconfinder.com/ajax/download/png/?id=43350&s=128
instead of :identicon
or others)Independently, both options work as expected, but when I put them together:
def gravatar_for(user, options = { :default => 'http://www.iconfinder.com/ajax/download/png/?id=43350&s=128', :size => 50 }) gravatar_image_tag(user.email.downcase, :alt => user.full_name, :class => 'gravatar', :gravatar => options) end
the size option is not applied, and the gravatar gets rendered in it's full size (128px in this case).
What am I doing wrong, or how can I achieve this combination?
I am getting this error after I installed the gem:
ActionView::Template::Error (undefined method `gravatar_image_tag' for #<#Class:0x1940c580x193ef18):
1:
app/views/users/show.html.erb:2:in '_app_views_users_show_html_erb__623389499_13233936__799847888'
I am using version 1.0.0.pre2, although I had the same error with 0.1.0.
I am Windows XP SP3, if that matters. Is this a routing issue?
Sorry, I am quite new to this and am running through a tutorial that uses this gem.
any help would be appreciated.
To simplify the use of a self-hosted gravatar service the hostname of gravatar should be configurable.
Thanks for considering adding this.
I'm in Rails 3 and I am getting this error message:
undefined method `configure' for GravatarImageTag:Module (NoMethodError)
Would be cool to be able to specify an option that would enable support for Hi DPI displays.
I think it could be fairly simple - right now, the "size" attribute is used for both the <img>
tag width and height, and the gravatar image URL. If there was a way to separate these two, so the <img>
width/height were say 40, and the gravatar request would use size=80, I think that would cover it...
Hi,
I use your great gem in my opensource project but it fails to use default image uri correctly in development and production. I have this code :
gravatar_image_tag user.email, :alt => user.name, :class => "preview", :gravatar => { :default => http://localhost:3000/assets/icons/user.png , :size => size }
And when I can't use gravatar image for user I have this uri :
http://gravatar.com/avatar/f393a47b554d5812bd0b59bf8b19de13?default=http%3A%2F%2Flocalhost%3A3000%2Fassets%2Ficons%2Fuser.png&size=16
This uri fails because when I execute on my brower redirect to :
http://i0.wp.com/localhost/assets/icons/user.png
And when I use github picture like in your README it works ('https://assets.github.com/images/gravatars/gravatar-140.png').
Do you have encounter a problem like this?
Thanks for your work
Luc Donnet
You can consume images just starting the url with //
instead of use configuration {secure: true}
. The browser uses the current page location's protocol when the img-src starts with //
.
Restart you server after you run 'bundle install'. Please don't log an issue here if you have not done a restart of your rails server at a minimum to try and resolve your problem.
@mdeering Are you still maintaining this project? Or this project dead?
Running on Ruby 2.7, I get this warning a lot:
vendor/bundle/ruby/2.7.0/gems/gravatar_image_tag-1.2.0/lib/gravatar_image_tag.rb:121: warning: URI.escape is obsolete
Everything still seems to work fine, but I'm afraid it might break on a newer version.
I'm not terribly worried about it, as every browser under the sun will correctly interpret this, but we're generating image tags that have something like
<img ... height="55px" width="55px">
The "px" isn't technically valid HTML, and the W3C validator will puke on it. This should be
<img ... height="55" width="55">
The code responsible is here...
The Gravatar URL output by gravatar_image_tag contains unescaped ampersands. A simple fix would be to change the parameter to join
the end of GravatarImageTag#url_params:89
from &
to &
.
Thanks!
Hi!
This
def self.url_params(gravatar_params)
return nil if gravatar_params.keys.size == 0
array = gravatar_params.map { |k, v| "#{k}=#{value_cleaner(v)}" }
"?#{array.join('&')}"
end
causes invalid html, if I run the http://validator.w3.org
Line 93, Column 122: & did not start a character reference. (& probably should have been escaped as &.)…e66872a973005f1dae67?default=identicon&secure=true&size=50" width="50" height=…
Line 93, Column 134: & did not start a character reference. (& probably should have been escaped as &.)…a973005f1dae67?default=identicon&secure=true&size=50" width="50" height="50" />
Changing the "&" to "&' would fix it..
Can you fix this, or should i provide a pull request?
I know it is just a little "error", but if all other validations pass it would be fine if also this last one pass :-)..
Matthias
Hi, is it possible to use gravatar_image_url in a model? or is it simply for views?
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
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.