2

What's the best way to generate <link rel="icon" sizes="196x196" href="my_android_icon.png"> in Rails for the asset pipeline? (https://developer.chrome.com/multidevice/android/installtohomescreen)

I could use <%= favicon_link_tag 'my_android_icon.png', :rel => "icon", :type => "image/png", size: "196x196" %> (How to set "shortcut icon" in rails?), but it doesn't feel right as Android homescreen icons aren't really favicons.

Community
  • 1
  • 1
Mark Boulder
  • 13,577
  • 12
  • 48
  • 78
  • 1
    I think this is fine but ideally you'll want a lot more, like Apple touch icons (boilerplate - https://github.com/sindre/webapp-icons). I'm not aware of any Gems for it, but you'll probably want to make a helper method to support them all (which might still use favicon_link_tag, just multiple times). – mahemoff Oct 05 '14 at 23:44
  • Thanks! Exactly what would this helper do? Also - any idea how webapp-icons compares to https://github.com/h5bp/mobile-boilerplate? – Mark Boulder Oct 06 '14 at 11:24
  • The helper would generate the HTML for a given size. You could then invoke it several times, one per size, in the HTML template. Or alternatively generate the whole thing programmatically so your template only includes one line to built them all. (There's really a need for a library for this.) – mahemoff Oct 06 '14 at 15:34
  • 1
    Here's an example of the kind of helper I'm talking about - https://gist.github.com/mahemoff/7c9de64236f84fb0f424 (just a basic example, would be great to expand it into a proper reusable gem to cover all the variants at https://mathiasbynens.be/notes/touch-icons as well as web app manifest standard). – mahemoff Nov 05 '14 at 12:04
  • 1
    Nice work, however I ended up just using `<%= content_tag :link, nil, href: "my_android_icon.png", rel: :icon, sizes: "196x196" %>` for the sizes over at https://github.com/h5bp/mobile-boilerplate/blob/master/index.html. – Mark Boulder Nov 05 '14 at 21:30

0 Answers0