retina_image_tag 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fastimage'
|
2
|
-
|
3
1
|
module RetinaImageTag
|
4
2
|
module ViewHelpers
|
5
3
|
|
@@ -9,32 +7,18 @@ module RetinaImageTag
|
|
9
7
|
end
|
10
8
|
|
11
9
|
|
12
|
-
def full_image_path
|
13
|
-
if Rails.env == 'development'
|
14
|
-
Rails.root.to_s+'/app/assets/images/'+@image
|
15
|
-
else
|
16
|
-
request.protocol + request.host_with_port + image_path(@image)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
10
|
def retina_image_tag(image, options = {})
|
22
11
|
@devicePixelRatio = cookies[:devicePixelRatio]
|
23
12
|
@options = options
|
24
13
|
@image = image # foo.jpg, subdir/foo.png
|
25
14
|
|
26
|
-
|
27
|
-
if @options[:size] == nil
|
28
|
-
@options[:size] = FastImage.size(full_image_path.delete '@2x').join("x")
|
29
|
-
end
|
30
|
-
|
31
15
|
case @devicePixelRatio
|
32
16
|
when '2'
|
33
17
|
retina_image 2
|
34
18
|
when '1.5'
|
35
19
|
retina_image 2
|
36
20
|
else
|
37
|
-
|
21
|
+
image_tag(@image, @options)
|
38
22
|
end
|
39
23
|
end
|
40
24
|
|