Simply retinify images
Sometimes you just want to retinify images you know to have @2x. retina.js doesn't work and query.retina tries to check if @2x files exist and in my case static was on another domain – Rackspace CloudFiles so it raises CORS alert. As it was very simple I decided to implement this few lines of code myself. :-) Okay, lazy but...
Anyway if you find it helpful for you feel free to use it! And have a nice day/night wherever you are !
$ ->
# Retina is here
if window.devicePixelRatio >= 2
retinaImages = $ 'img[data-retina]'
retinaImages.each (i) ->
retinaImages[i].src = $(retinaImages[i]).data('retina')
[http://oshalakhin.github.io/retinify.js/]: http://oshalakhin.github.io/retinify.js/
Written by Olexandr Shalakhin
Related protips
3 Responses
May be there could be more improvements someone will need so feel free to ask or contribute http://oshalakhin.github.io/retinify.js/
Hey Oshalakhin
Could you show a markup example please. Interested in the plugin.
Thanks.
Sure! For images you want to retinify just add data-retina:
<img src="some/image.png" data-retina="some/image@2x.png">Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside