-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·306 lines (274 loc) · 14.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Retina Images</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="fb:admins" content="1206001117">
<meta name="google-site-verification" content="ZChUvbnrem_S4PxM6izeLnjRgBKXUp0OIknaZqjo8U8">
<meta name="description" content="Retina Images serves different images based on the device being used by the viewer, all you have to do is create a high-res version of each image.">
<meta name="author" content="Jeremy Worboys">
<script>(function(w){var dpr=((w.devicePixelRatio===undefined)?1:w.devicePixelRatio);if(!!w.navigator.standalone){var r=new XMLHttpRequest();r.open('GET','/retinaimages.php?devicePixelRatio='+dpr,false);r.send()}else{document.cookie='devicePixelRatio='+dpr+'; path=/'}})(window)</script>
<link rel="stylesheet" href="css/style.css">
<script src="js/libs/modernizr-2.5.3.min.js"></script>
<script>
var _gaq=[['_setAccount','UA-30234355-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</head>
<body id="home" onload="prettyPrint();" data-spy="scroll">
<noscript><style id="devicePixelRatio" media="only screen and (-moz-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)">#devicePixelRatio{background-image:url("/retinaimages.php?devicePixelRatio=2")}</style></noscript>
<div id="navbar" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#home">Retina Images</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#works">How it Works</a></li>
<li><a href="#setupserver">Setup Your Server</a></li>
<li><a href="#setuphtml">HTML Images</a></li>
<li><a href="#setupcss">CSS Images</a></li>
<li><a href="#fileexample">File Example</a></li>
<li><a href="#benefits">Benefits</a></li>
<li><a href="#plugins">Plugins</a></li>
<li><a href="#thanks">Thanks</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<header>
<div class="inner">
<h1>Retina Images</h1>
<p>Automatically serve high-res images, to those who'll appreciate them.</p>
<p class="download-info">
<a href="https://github.com/Retina-Images/Retina-Images/" onClick="javascript: _gaq.push(['_trackPageview', '/GH/view']);" class="btn btn-primary btn-large">View project <span class="hidden-phone">on GitHub</span></a>
<a href="https://github.com/Retina-Images/Retina-Images/zipball/master" onClick="javascript: _gaq.push(['_trackPageview', '/GH/zipball']);" class="btn btn-large">Download <span class="hidden-phone">Retina Images</span> <small>(v1.7.2)</small></a>
</p>
</div>
<div class="bs-links">
<ul class="quick-links">
<li><iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=Retina-Images&repo=Retina-Images&type=watch&count=true" width="112" height="20" style="background:transparent;border:0;overflow:hidden;" allowtransparency="true" frameborder="0" scrolling="0"></iframe></li>
<li><iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=Retina-Images&repo=Retina-Images&type=fork&count=true" width="98" height="20" style="background:transparent;border:0;overflow:hidden;" allowtransparency="true" frameborder="0" scrolling="0"></iframe></li>
</ul>
<div class="quick-links sharrre-container">
<div id="shareme" data-url="http://retinaimag.es" data-text="Retina Images: Automatically serve high-res images, to those who'll appreciate them."></div>
</div>
</div>
</header>
<hr id="about" class="soften">
<section>
<figure class="iphone-demo pull-right visible-desktop">
<div class="iphone"></div>
<figcaption>
<span class="h3">
Mouse-over to see the effect of Retina Images<br>
<small>This demo actually replicates what happens on retina devices</small>
</span>
</figcaption>
</figure>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>About Retina Images</h1>
<p>Retina Images serves different images based on the device being used by the viewer.</p>
<p>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 <code><img></code> tags (providing they have a height or width).</p>
<div class="row display-demo hidden-desktop">
<div class="span5 offset1 non-retina">
<figure>
<img src="img/settings-small.png" width="118" alt="Example of non-retina image">
<figcaption class="h4">Without Retina Images.</figcaption>
</figure>
</div>
<div class="span5">
<figure>
<img src="img/settings-large.png" width="118" alt="Example of retina image">
<figcaption class="h4">With Retina Images.</figcaption>
</figure>
</div>
</div>
</section>
<hr id="works" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>How it Works</h1>
<ol>
<li><p>When the page loads on the viewers device, a cookie holding the <code>devicePixelRatio</code> is set by either JavaScript or CSS (if JS is disabled).</p></li>
<li><p>When an image is requested by the server, the <code>.htaccess</code> file tells <code>retinaimages.php</code> to serve the image instead.</p></li>
<li><p><code>retinaimages.php</code> then checks for the following conditions:</p>
<ul>
<li><p>A cookie holding <code>devicePixelRatio</code> exists.</p></li>
<li><p>The value set in the cookie is greater than 1.</p></li>
<li><p>A high-res version of the image exists.</p></li>
</ul>
</li>
<li><p>If any of the above are false, it will send the regular image. Otherwise, the high-res image is sent in its place.</p></li>
</ol>
</section>
<hr id="setupserver" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>Setup Your Server</h1>
<p>Installing Retina Images is really quite simple:</p>
<ol>
<li><p>Drop the <code>retinaimages.php</code> and <code>.htaccess</code> file into your document-root (usually <code>public_html</code>).</p>
<p><span class="label label-important">Warning!</span> <strong>Do not overwrite a this file if it already exists</strong>, simply copy the contents into your existing one.</p></li>
<li><p>In the <code><head></code> section of each page <strong>before any CSS</strong> put the following:</p>
<pre class="prettyprint"><script>(function(w){var dpr=((w.devicePixelRatio===undefined)?1:w.devicePixelRatio);if(!!w.navigator.standalone){var r=new XMLHttpRequest();r.open('GET','/retinaimages.php?devicePixelRatio='+dpr,false);r.send()}else{document.cookie='devicePixelRatio='+dpr+'; path=/'}})(window)</script>
<noscript><style id="devicePixelRatio" media="only screen and (-moz-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)">html{background-image:url("/retinaimages.php?devicePixelRatio=2")}</style></noscript></pre></li>
<li><p>For every image that you would like to have served at high-res, create an image at twice the size and save it with <code>@2x</code> at the end of the filename (before the file extension). <a href="#fileexample">See the example</a>.</p></li>
</ol>
</section>
<hr id="setuphtml" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>HTML Images</h1>
<p>HTML images are the easiest to get setup, chances are they will work without any change.</p>
<p>All you have to worry about, is that an image with a high-res counterpart must have a width or height (or both) attribute specified.</p>
<pre class="prettyprint"><img src="my-image.png" alt="My awesome image" width="300" height="90"></pre>
</section>
<hr id="setupcss" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>CSS Images</h1>
<p>CSS images will usually require some work, all CSS images must have a suitable <code>background-size</code> property to work correctly. Below are three of the simplest methods to contain your retina background images.</p>
<div class="row setupcss">
<div class="span4">
<h3>CSS Background Images</h3>
<p>A static pixel value equal to the size of the regular (non-retina) image.</p>
<pre class="prettyprint">.some-selector {
background-image: url("my-image.png");
background-size: 300px 90px;
}</pre>
</div>
<div class="span8 row">
<h3>Image Replacement</h3>
<p>If the (standard size) image is the same size as the box you may either the following for convenience as they will produce the same result.</p>
<div class="row">
<div class="span4">
<pre class="prettyprint">.some-selector {
background-image: url("my-image.png");
background-size: 100% 100%;
}</pre>
</div>
<div class="span4">
<pre class="prettyprint">.some-selector {
background-image: url("my-image.png");
background-size: cover;
}</pre>
</div>
</div>
</div>
</div>
</section>
<hr id="fileexample" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>File Example</h1>
<div class="row filename-demo">
<div class="span5 offset1 small">
<p class="h4">Served to non-retina devices.</p>
<figure>
<img src="img/settings-small.png" width="59" alt="Example of regular image">
<figcaption>settings.png<small>59px × 59px</small></figcaption>
</figure>
</div>
<div class="span5">
<p class="h4">Served only to retina devices.</p>
<figure>
<img src="img/settings-large.png" width="118" alt="Example of double size retina image">
<figcaption>[email protected]<small>118px × 118px</small></figcaption>
</figure>
</div>
</div>
</section>
<hr id="benefits" class="soften">
<section>
<h1 class="visuallyhidden">Benefits and Drawbacks</h1>
<div class="row">
<div class="span6">
<h2 class="h1">Benefits</h2>
<ul>
<li><p>Only one image is downloaded by the viewer.</p></li>
<li><p>All standard raster images (.jpg, .png, .gif & .bmp) are able to be served as high-res.</p></li>
<li><p>Fallback to regular image if high-res image isn’t available.</p></li>
<li><p>Fallback to regular image if JavaScript and CSS or Cookies are disabled.</p></li>
</ul>
</div>
<div class="span6">
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h2 class="h1">Drawbacks</h2>
<ul>
<li><p><code><img></code> tags must have either a width or height attribute specified.</p></li>
<li><p>CSS background images must have a <code>background-size</code> property. See <a href="#setupcss">CSS Images</a> for details.</p></li>
</ul>
</div>
</div>
</section>
<hr id="plugins" class="soften">
<section>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1>Plugins</h1>
<div class="row">
<div class="span6">
<dl>
<dt><a href="http://wordpress.org/extend/plugins/wp-retina-2x/">WP Retina 2x</a> <small>by <a hre="http://www.meow.fr/">Jordy Meow</a> for WordPress</small></dt>
<dd>
<p><span class="label label-success">Recommended for WordPress</span></p>
<q>“Make your website look beautiful and smooth on Retina (high-DPI) displays.”</q>
</dd>
</dl>
</div>
</div>
<p><span class="label label-info">Note:</span> These are plugins that I am aware of that use Retina Images. If you have developed (or are developing) a plugin that uses Retina Images, <a href="mailto:[email protected]">send me a email</a> and I may link it up here.</p>
</section>
<hr id="thanks" class="soften">
<section class="thanks">
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<h1><small>So Long, and</small> Thanks <small>for All the Fish</small></h1>
<div class="row">
<div class="span6">
<dl>
<dt><a href="http://twitter.github.com/bootstrap">Twitter</a></dt>
<dd>for releasing Bootstrap which the style of this page is built on.</dd>
<dt><a href="http://mattwilcox.net/">Matt Wilcox</a></dt>
<dd>for creating <a href="http://adaptive-images.com/">adaptive-images</a> which spawned my idea to create this.</dd>
<dt><a href="http://benjaminnathan.nl">Benjamin Nathan</a></dt>
<dd>for the settings icon used in the file and display (only on small-screen and touch devices) demos above.</dd>
</dl>
</div>
<div class="span6">
<dl>
<dt><a href="http://html5boilerplate.com/">H5BP Team</a></dt>
<dd>for creating H5BP which the structure of this page is built on.</dd>
<dt><a href="http://marshallbock.com">Marshall Bock</a></dt>
<dd>for the iPhone 4S mockup used in the demo above (only on large-screen and non-touch devices).</dd>
</dl>
</div>
</div>
</section>
<footer>
<p class="pull-right back-to-top"><a href="#home">Back to top</a></p>
<p><span class="label">No images were blurred in the making of this website.</span></p>
<p>Retina Images by <a href="http://twitter.com/jeremyworboys/" rel="me">Jeremy Worboys</a> is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a></p>
</footer>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
<!-- scripts concatenated and minified via build script -->
<script src="js/bootstrap.js"></script>
<script src="js/prettify.js"></script>
<script src="js/plugins.js"></script>
<script src="js/script.js"></script>
<!-- end scripts -->
</body>
</html>