Skip to main content

WHAT IS RETINA GRAPHIC IMAGE HOW IT WORK AND HOW TO USE IT

retina.js is an open source script that makes it easy to serve 
high-resolution images to devices with retina displays



How it works

When your users load a page, retina.js checks each image on the page to see if there is a high-resolution version of that image on your server. If a high-resolution variant exists, the script will swap in that image in-place.
The script assumes you use Apple's prescribed high-resolution modifier (@2x) to denote high-resolution image variants on your server.
For example, if you have an image on your page that looks like this:
<img src="/images/my_image.png" />
The script will check your server to see if an alternative image exists at this path:
"/images/my_image@2x.png"


JavaScript

The JavaScript helper script automatically replaces images on your page with high-resolution variants (if they exist). To use it, download the script and include it at the bottom of your page.
  1. Place the retina.js file on your server
  2. Include the script on your page

    <script type="text/javascript" src="/scripts/retina.js"></script>

    (put it at the bottom of your template, before your closing </body> tag)
  3. That's it!

LESS

The LESS CSS mixin is a helper for applying high-resolution background images in your stylesheet. You provide it with an image path and the dimensions of the original-resolution image. The mixin creates a media query specifically for Retina displays, changes the background image for the selector elements to use the high-resolution (@2x) variant and applies a background-size of the original image in order to maintain proper dimensions. To use it, download the mixin, import or include it in your LESS stylesheet, and apply it to elements of your choice.

Steps:

Syntax:
.at2x(@path, [optional] @width: auto, [optional] @height: auto);

Steps:

  1. Add the .at2x() mixin from retina.less to your LESS stylesheet
  2. In your stylesheet, call the .at2x() mixin anywhere instead of using background-image

    #logo { .at2x('/images/my_image.png', 200px, 100px); }

    Will compile to:

    #logo { background-image: url('/images/my_image.png'); } @media all and (-webkit-min-device-pixel-ratio: 1.5) { #logo { background-image: url('/images/my_image@2x.png'); background-size: 200px 100px; } }

Comments

Popular posts from this blog

Wo-commerce sidebar navigation

There is Plus Minus Image you can change it in your own code

How to add attribute in input type onload

Add this script this will target your input type submit and set an attribute on it when page load. <script> function functionAddAttribute(){     $("input:submit").attr("accesskey","g"); }; window.onload = functionAddAttribute; </script> <noscript>Your browser does not support JavaScript!</noscript> This is html <input type="submit" value="this is button" />

HOW TO IMPLEMENT ADAPTIVE IMAGE IN WORDPRESS

If you don't know about Adaptive image please Read my last artical. STEP:1 COPY .htaccess , Adaptive-image.php, ai-cookie.php, DS_Store file in your root directory STEP 2: CREATE folder in wp-contant/uploads/adaptive/ai-cache if .htaccess file already exist then pest this code in it but be carefull take its backup CODE #START Adaptive-Images #Add any directories you wish to omit from the Adaptive-Images process on a new line. #Omit plugins, wp-includes and wp-admin content. RewriteCond %{REQUEST_URI} !wp-content/plugins RewriteCond %{REQUEST_URI} !wp-includes RewriteCond %{REQUEST_URI} !wp-admin #Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories #to adaptive-images.php so we can select appropriately sized versions RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php #END Adaptive-Images UNDER # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On STEP3: Open Adaptive-image.php change with it $cache_path    = "wp-content/upl...