cloudflare_image_resizing 1.0.0 → 1.0.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709f406b386731659665c383a6dd113949dcbb04b924bafe36bb6c162e99442a
|
4
|
+
data.tar.gz: e8befe82c7faa217d0c96d3e47cc74c4a901323a08f917a86c8858b037f22888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e7f42b801be3450c867ca221d0155748a500cfc410ed48e3768c11fcfc0ec6925fb7a17b4ce64fc71da0d51cc619b9b7324ec41c042dc58ece161ac5ade089
|
7
|
+
data.tar.gz: 15d3d5c613a35401d76cfbac7873d7502f5513627bd893c3ac25116319fe9061fd8eeaf2e3b5e7951740db943d4e80385f71eaf9411c57e898ffc8b5bf47440f
|
data/README.md
CHANGED
@@ -60,7 +60,7 @@ gem "cloudflare_image_resizing"
|
|
60
60
|
|
61
61
|
## Configuration
|
62
62
|
|
63
|
-
You can use an initializer to configure the `enabled` flag (defaults to `true` for non-local environments, checking `Rails.env.local?`.)
|
63
|
+
You can use an initializer to configure the `enabled` flag (defaults to `true` for non-local environments (production), checking `Rails.env.local?`.)
|
64
64
|
|
65
65
|
```ruby
|
66
66
|
Rails.application.config.cloudflare_image_resizing.enabled = false
|
@@ -11,11 +11,12 @@ module CloudflareImageResizing
|
|
11
11
|
# <%= resized_image_tag @user.avatar, resize: {width: 100, fit: "crop"}, alt: "Cropped avatar" %>
|
12
12
|
def resized_image_tag(image, options = {})
|
13
13
|
resize_options = options.delete(:resize) || {}
|
14
|
+
# note: srcset needs to encode the commas in the URLs (%2C) to avoid confusing it with commas between variants.
|
14
15
|
image_tag(
|
15
16
|
resized_image(image, resize_options),
|
16
|
-
options.reverse_merge(srcset: "#{resized_image(image, resize_options.merge(dpr: 1))},
|
17
|
-
#{resized_image(image, resize_options.merge(dpr: 2))} 2x,
|
18
|
-
#{resized_image(image, resize_options.merge(dpr: 3))} 3x".gsub(/\s+/, " "))
|
17
|
+
options.reverse_merge(srcset: "#{resized_image(image, resize_options.merge(dpr: 1)).gsub(",", "%2C")},
|
18
|
+
#{resized_image(image, resize_options.merge(dpr: 2)).gsub(",", "%2C")} 2x,
|
19
|
+
#{resized_image(image, resize_options.merge(dpr: 3)).gsub(",", "%2C")} 3x".gsub(/\s+/, " "))
|
19
20
|
)
|
20
21
|
end
|
21
22
|
|