shimmer 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d82a8e015623e83b0381e182752ede22419e26c40b9a730536f6020793818b75
4
- data.tar.gz: 00766a05189358517092bcbc6ef958d26acbfae14efb98b45f81c3b848cfaffa
3
+ metadata.gz: ef9968ad0ba48627fb9adb95ae2702575de2f9fa1b1e56ba3f30c9872d9cde38
4
+ data.tar.gz: c8bef4d12c776820c96e810a1e3ae1cb7c6717f029d5ac532b7fc05e595005d2
5
5
  SHA512:
6
- metadata.gz: d9e72dcab3004ea3c720a1b7041ee0714e4beded68cfa8caa9f5a1213fbe3ece9cf82030437be32c1532c85c67e489b159fa39f13392664c9c5f3520f8ba67f6
7
- data.tar.gz: e8e15ddcc1aedbad180f0b62dd11af6791d8ef35aa5139e7f0e7ffdead8551052f8ccbed36c143ae39868e44ca381ed27737e036d93dca8b9e5b8cffd125fae5
6
+ metadata.gz: 2c2dfb753bd6ac9afc4a4ba726c99a53a1dce6e1843c6b5bcdc320671ffcb2da0a8575ff357fd1294b3c25beed7a2026e144dffc0873a1a6ded6b78318ac737a
7
+ data.tar.gz: 9c00815fe851db16bd4ebf925d2ba2beb8b84c729351982f430721d6c7a395d21fd162add118a82a80df13ed8b97c67f76ac8177dadac29573c9e9604d8f9687
@@ -2,6 +2,16 @@
2
2
 
3
3
  module Shimmer
4
4
  module FileHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ ActiveSupport.on_load(:action_view) do
9
+ include Shimmer::FileAdditions
10
+ end
11
+ end
12
+ end
13
+
14
+ module FileAdditions
5
15
  def image_tag(source, **options)
6
16
  return nil if source.blank?
7
17
 
@@ -9,19 +19,27 @@ module Shimmer
9
19
  attachment = source
10
20
  width = options[:width]
11
21
  height = options[:height]
12
- source = image_file_url(source, width: width, height: height)
22
+ source = image_file_path(source, width: width, height: height)
13
23
  options[:loading] = :lazy
14
- options[:srcset] = "#{source} 1x, #{image_file_url(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
24
+ options[:srcset] = "#{source} 1x, #{image_file_path(attachment, width: width.to_i * 2, height: height ? height.to_i * 2 : nil)} 2x" if options[:width].present?
15
25
  end
16
26
  super source, options
17
27
  end
18
28
 
29
+ def image_file_path(source, width: nil, height: nil)
30
+ image_file_proxy(source, width: width, height: height).path
31
+ end
32
+
19
33
  def image_file_url(source, width: nil, height: nil)
34
+ image_file_proxy(source, width: width, height: height).url
35
+ end
36
+
37
+ def image_file_proxy(source, width: nil, height: nil)
20
38
  return if source.blank?
21
39
  return source if source.is_a?(String)
22
40
 
23
41
  blob = source.try(:blob) || source
24
- Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height).url
42
+ Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
25
43
  end
26
44
  end
27
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.16"
4
+ VERSION = "0.0.17"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens