dimensions-rails 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/dimensions-rails.rb +7 -5
- data/lib/dimensions-rails/version.rb +1 -1
- data/spec/helper/dimensions-rails_spec.rb +6 -0
- metadata +16 -16
data/README.md
CHANGED
@@ -31,6 +31,8 @@ gem 'dimensions-rails'
|
|
31
31
|
|
32
32
|
Just use the `image_tag` rails helper as usual, the `:size` options will be magically added by `dimensions-rails` elves!
|
33
33
|
|
34
|
+
If for any reason you need to disable `dimensions-rails` just pass `:dimensions => false` to `image_tag`.
|
35
|
+
|
34
36
|
|
35
37
|
## Contributing
|
36
38
|
|
data/lib/dimensions-rails.rb
CHANGED
@@ -15,12 +15,14 @@ module Dimensions
|
|
15
15
|
# https://developers.google.com/speed/docs/best-practices/rendering#SpecifyImageDimensions
|
16
16
|
#
|
17
17
|
def image_tag source, options = {}
|
18
|
-
|
18
|
+
disable_dimensions = options[:dimensions] == false
|
19
|
+
|
20
|
+
unless disable_dimensions or options[:size] or options[:width] or options[:height]
|
19
21
|
fs_path = begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
asset_paths.asset_for(source, nil)
|
23
|
+
rescue Sprockets::FileOutsidePaths
|
24
|
+
nil
|
25
|
+
end if respond_to? :asset_paths
|
24
26
|
|
25
27
|
fs_path = fs_path.present? ? fs_path.to_path : File.join(::Rails.public_path, source)
|
26
28
|
|
@@ -18,4 +18,10 @@ describe ApplicationHelper, :type => :helper do
|
|
18
18
|
tag.should match('height="64"')
|
19
19
|
tag.should match('width="50"')
|
20
20
|
end
|
21
|
+
|
22
|
+
it 'is disabled passing false to the :dimensions option' do
|
23
|
+
tag = helper.image_tag('/outsiders/rails.png', :dimensions => false)
|
24
|
+
tag.should_not match('height=')
|
25
|
+
tag.should_not match('width=')
|
26
|
+
end
|
21
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimensions-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dimensions
|
16
|
-
requirement: &
|
16
|
+
requirement: &70142348500100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70142348500100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: railties
|
27
|
-
requirement: &
|
27
|
+
requirement: &70142348496960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70142348496960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: actionpack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70142348494600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70142348494600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &70142348509020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70142348509020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &70142348506380 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70142348506380
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &70142348504320 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '2.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70142348504320
|
80
80
|
description: Use dimensions by @sstephenson to add automatic images size and improve
|
81
81
|
browser rendering
|
82
82
|
email:
|
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
segments:
|
148
148
|
- 0
|
149
|
-
hash:
|
149
|
+
hash: 2160485572906887229
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
none: false
|
152
152
|
requirements:
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
segments:
|
157
157
|
- 0
|
158
|
-
hash:
|
158
|
+
hash: 2160485572906887229
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project:
|
161
161
|
rubygems_version: 1.8.17
|