How do I use a favicon with an asset pipeline?
I am implementing a favicon using an online generator ( http://realfavicongenerator.net , but other generators like www.favicon-generator.org work the same). The generator supplies almost 30 files (images for Android, Apple, different sizes, etc.), so I put all these files in the asset pipeline ( assets/images/favicons/
) and not in the shared folder (which would otherwise be so cluttered).
The files include xml file browserconfig.xml
and json file manifest.json
(not sure what they are for). In the header, I download both files using:
<%= content_tag :meta, nil, content: image_path("favicons/browserconfig.xml"), name: 'msapplication-config' %>
<%= content_tag :link, nil, href: image_path("favicons/manifest.json"), rel: :manifest %>
Can it be used image_path
this way? (although they are not images, I put all the favicon files in one folder inside assets/images/favicons
)
Additionally, both the xml and json file contain links to favicon images (see below) that are now in the asset pipeline. Thus, in its current form, these links fail. How can I link to images in xml and json files?
browserconfig.xml:
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<TileColor>#fff8dc</TileColor>
</tile>
</msapplication>
</browserconfig>
manifest.json:
{
"name": "AppName",
"icons": [
{
"src": "\/android-chrome-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-chrome-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
# etc.
]
}
source to share