retina_image_tag 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -5
- data/lib/retina_image_tag/version.rb +1 -1
- data/lib/retina_image_tag/view_helpers.rb +25 -12
- data/retina_image_tag.gemspec +1 -0
- metadata +25 -3
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
retina_image_tag is a ViewHelper for Rails 3.1. in contrast to the normal Rails image_tag knows the retina_image_tag if the user invokes an image on a Apple Retina Display.
|
4
4
|
|
5
|
-
[![Dependency Status](https://gemnasium.com/ffaerber/retina_image_tag.png)](https://gemnasium.com/ffaerber/retina_image_tag)
|
6
|
-
|
7
5
|
|
8
6
|
### Retina Display
|
9
7
|
The Retina Display on the iPhone4 and iPad3 doubles the pixel resolution of the display.
|
@@ -13,7 +11,7 @@ You can think about a full screen display with dimensions of 320x480 for iPhone4
|
|
13
11
|
The '@2x' naming convention will be instantly familiar to any iOS developer. It's simply a way of naming an alternate, high-resolution version of an image so that it will be recognized and used by high-resolution Retina Displays.
|
14
12
|
|
15
13
|
### Example
|
16
|
-
herokuapp: <http://retinaimagetag
|
14
|
+
herokuapp: <http://retinaimagetag.herokuapp.com/>
|
17
15
|
|
18
16
|
sourcecode: <https://github.com/ffaerber/retina_image_tag_demoapp/>
|
19
17
|
|
@@ -36,8 +34,8 @@ And then execute:
|
|
36
34
|
|
37
35
|
|
38
36
|
|
39
|
-
## Usage
|
40
|
-
|
37
|
+
## Usage via Asset Pipeline
|
38
|
+
|
41
39
|
```erb
|
42
40
|
<%= retina_image_tag 'foo.jpg', :size => "400x400" %>
|
43
41
|
```
|
@@ -62,6 +60,16 @@ after:
|
|
62
60
|
* `subdir/bar.png (500×278px)`
|
63
61
|
|
64
62
|
|
63
|
+
## Usage via CarrierWave
|
64
|
+
|
65
|
+
```erb
|
66
|
+
<%= retina_image_tag @picture.image.thumb %>
|
67
|
+
```
|
68
|
+
|
69
|
+
Uploader: <https://github.com/ffaerber/retina_image_tag_demoapp/blob/master/app/uploaders/image_uploader.rb>
|
70
|
+
|
71
|
+
|
72
|
+
|
65
73
|
## Contributing
|
66
74
|
|
67
75
|
1. Fork it
|
@@ -1,26 +1,39 @@
|
|
1
1
|
module RetinaImageTag
|
2
2
|
module ViewHelpers
|
3
|
-
|
3
|
+
|
4
|
+
|
4
5
|
def retina_image( pixel_ratio )
|
5
|
-
|
6
|
-
|
6
|
+
if @image.class.superclass.superclass.to_s == "CarrierWave::Uploader::Base"
|
7
|
+
image_tag(@image, :size => @image.class.sizes[@image.version_name].join('x'))
|
8
|
+
else
|
9
|
+
insert_on = -File.extname(@image).size-1
|
10
|
+
image_tag(@image.insert(insert_on, "@#{pixel_ratio}x"), @options)
|
11
|
+
end
|
7
12
|
end
|
8
|
-
|
9
|
-
|
13
|
+
|
10
14
|
def retina_image_tag(image, options = {})
|
11
|
-
@devicePixelRatio = cookies[:devicePixelRatio]
|
15
|
+
@devicePixelRatio = cookies[:devicePixelRatio].to_i
|
12
16
|
@options = options
|
13
|
-
@image = image
|
17
|
+
@image = image
|
14
18
|
|
15
19
|
case @devicePixelRatio
|
16
|
-
when
|
20
|
+
when 4
|
21
|
+
retina_image 2
|
22
|
+
when 3
|
17
23
|
retina_image 2
|
18
|
-
when
|
24
|
+
when 2
|
25
|
+
retina_image 2
|
26
|
+
when 1.5
|
19
27
|
retina_image 2
|
20
28
|
else
|
21
|
-
|
29
|
+
if @image.class.superclass.superclass.to_s == "CarrierWave::Uploader::Base"
|
30
|
+
image_tag(@image.normal)
|
31
|
+
else
|
32
|
+
image_tag(@image, @options)
|
33
|
+
end
|
22
34
|
end
|
23
35
|
end
|
24
|
-
|
36
|
+
|
25
37
|
end
|
26
|
-
end
|
38
|
+
end
|
39
|
+
|
data/retina_image_tag.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retina_image_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.13.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.12.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.12.0
|
46
62
|
description: ! 'A high-resolution image is loaded when the retina_image_tag is called
|
47
63
|
from a retina display '
|
48
64
|
email:
|
@@ -78,15 +94,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
94
|
- - ! '>='
|
79
95
|
- !ruby/object:Gem::Version
|
80
96
|
version: '0'
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
hash: 2815526574589731245
|
81
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
101
|
none: false
|
83
102
|
requirements:
|
84
103
|
- - ! '>='
|
85
104
|
- !ruby/object:Gem::Version
|
86
105
|
version: '0'
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
hash: 2815526574589731245
|
87
109
|
requirements: []
|
88
110
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.23
|
90
112
|
signing_key:
|
91
113
|
specification_version: 3
|
92
114
|
summary: A high-resolution image is loaded when the retina_image_tag is called from
|