retina_image_tag 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,29 +2,23 @@ module RetinaImageTag
|
|
2
2
|
module ViewHelpers
|
3
3
|
|
4
4
|
def retina_image( pixel_ratio )
|
5
|
-
|
6
|
-
image_tag(@
|
5
|
+
insert_on = -File.extname(@image).size-1
|
6
|
+
image_tag(@image.insert(insert_on, "@#{pixel_ratio}x"), @options)
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
10
|
def retina_image_tag(image, options = {})
|
11
11
|
@devicePixelRatio = cookies[:devicePixelRatio]
|
12
12
|
@options = options
|
13
|
-
@image = image
|
14
|
-
|
15
|
-
@file_path = image_path(@image)
|
16
|
-
@file_ext = File.extname(@file_path) # .jpg, .png
|
17
|
-
@file_name = File.basename(@image, @file_ext) # pic1, foo
|
18
|
-
@file_dirname = File.dirname(@file_path)
|
19
|
-
|
20
|
-
|
13
|
+
@image = image # foo.jpg, subdir/foo.png
|
14
|
+
|
21
15
|
case @devicePixelRatio
|
22
16
|
when '2'
|
23
|
-
retina_image
|
17
|
+
retina_image 2
|
24
18
|
when '1.5'
|
25
|
-
retina_image
|
19
|
+
retina_image 2
|
26
20
|
else
|
27
|
-
image_tag(@
|
21
|
+
image_tag(@image, @options)
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|