imgix-rails 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/imgix/rails/tag.rb +14 -5
- data/lib/imgix/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b03c93258d32db083dca271b49348a489b1c2f61
|
4
|
+
data.tar.gz: 2561fb0a35d24508727276d2b9cd33bb5e79bf27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1559d5951079e2fd3b0aab23862d906e9d4bb2cb323e9bf1968d3f4692ea3ba91dd5022663267acaff2e760f9a43560cca32552eafa04cd2f0244f6cd4b7c9e4
|
7
|
+
data.tar.gz: 018673c10d607f589719475175cc38ecd67d03efc2e3823fe9aae13aaa9f09977c669a9161b22698c8217f8bedaacd310243fc387d6f4b81ffaa873cda8bbb3e
|
data/README.md
CHANGED
@@ -102,6 +102,12 @@ Then rendering the portrait in your application is very easy:
|
|
102
102
|
<%= profile_image_tag(@user) %>
|
103
103
|
```
|
104
104
|
|
105
|
+
If you already know all the exact widths you need images for, you can specify that by passing the `widths` option as an array. In this case, imgix-rails will only generate `srcset` pairs for the specified `widths`.
|
106
|
+
|
107
|
+
```erb
|
108
|
+
<%= ix_image_tag('/unsplash/hotairballoon.jpg', { widths: [320, 640, 960, 1280] w: 300, h: 500, fit: 'crop', crop: 'right', alt: 'A hot air balloon on a sunny day' }) %>
|
109
|
+
```
|
110
|
+
|
105
111
|
|
106
112
|
<a name="ix_picture_tag"></a>
|
107
113
|
### ix_picture_tag
|
data/lib/imgix/rails/tag.rb
CHANGED
@@ -29,15 +29,17 @@ protected
|
|
29
29
|
|
30
30
|
def srcset(opts=@options)
|
31
31
|
@source = replace_hostname(@source)
|
32
|
-
|
32
|
+
widths = opts[:widths] || target_widths
|
33
|
+
|
34
|
+
widths.map do |width|
|
33
35
|
srcset_options = opts.slice(*self.class.available_parameters)
|
34
|
-
srcset_options[:w] =
|
36
|
+
srcset_options[:w] = width
|
35
37
|
|
36
38
|
if opts[:w].present? && opts[:h].present?
|
37
|
-
srcset_options[:h] = (
|
39
|
+
srcset_options[:h] = (width * (opts[:h].to_f / opts[:w])).round
|
38
40
|
end
|
39
41
|
|
40
|
-
"#{ix_image_url(@source, srcset_options)} #{
|
42
|
+
"#{ix_image_url(@source, srcset_options)} #{width}w"
|
41
43
|
end.join(', ')
|
42
44
|
end
|
43
45
|
|
@@ -137,9 +139,16 @@ private
|
|
137
139
|
min_screen_width_required = @options[:min_width] || SCREEN_STEP
|
138
140
|
max_screen_width_required = @options[:max_width] || MAXIMUM_SCREEN_WIDTH
|
139
141
|
|
140
|
-
(device_widths + screen_widths).select do |w|
|
142
|
+
widths = (device_widths + screen_widths).select do |w|
|
141
143
|
w <= max_screen_width_required && w >= min_screen_width_required
|
142
144
|
end.compact.uniq.sort
|
145
|
+
|
146
|
+
# Add exact widths for 1x, 2x, and 3x devices
|
147
|
+
if @options[:w]
|
148
|
+
widths.push(@options[:w], @options[:w] * 2, @options[:w] * 3)
|
149
|
+
end
|
150
|
+
|
151
|
+
widths
|
143
152
|
end
|
144
153
|
|
145
154
|
def device_widths
|
data/lib/imgix/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgix-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Sutton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: imgix
|