Giter VIP home page Giter VIP logo

retina-images's Introduction

Retina Images

Retina Images serves different images based on the device being used by the viewer.

Once setup on your website (very simple!) all you have to do is create a high-res version of each image you would like optimised for retina screens and all the work is done for you. You don’t even need to change any <img> tags (providing they have a height or width).to change any <img> tags.

How it Works

  1. When the page loads on the viewers device, a cookie holding the devicePixelRatio is set by either JavaScript or CSS (if JS is disabled).
  2. When an image is requested by the server, the .htaccess file tells retinaimages.php to serve the image instead.
  3. retinaimages.php then checks for the following conditions:
    • A cookie holding devicePixelRatio exists.
    • The value set in the cookie is greater than 1.
    • A high-res version of the image exists.
  4. If any of the above are false, it will send the regular image. Otherwise, the high-res image is sent in its place.

Installation & Examples

Visit http://retina-images.complexcompulsions.com for installation instructions and a set of demonstrations.

Benfits

  • Only one image is downloaded by the viewer.
  • All standard raster images (.jpg, .png, .gif & .bmp) are able to be served as high-res.
  • Fallback to regular image if high-res image isn’t available.
  • Fallback to regular image if JavaScript and CSS or Cookies are disabled.

Drawbacks

  • <img> tags must have either a width or height attribute specified.
  • CSS background images must have a background-size property. See CSS Images for details.

License

Retina Images by Jeremy Worboys is licensed under a Creative Commons Attribution 3.0 Unported License

retina-images's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.