active_storage-blurhash 0.1.5 → 0.1.7

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: d10bff7b9f51b5a7079c2e44fe8d411b6268879bf8b2276de1eb8c3e4d30b43c
4
- data.tar.gz: 3120b4c55cdf29ff5dee38918dc1f638b9dcde9117fda46d55dd297040f893e7
3
+ metadata.gz: 1c8e33dbe45f2399fdea2c071c8c8847e4a08a1cfea9ed09146b641dc4259e14
4
+ data.tar.gz: d61942e08ca7f9915d356123104a9b323f28f9758e3c1112ffdc64bb4876959a
5
5
  SHA512:
6
- metadata.gz: f45ceb47085f58cbecce509cb29b8c37921a810380b99f97a06eab68724af1074cc5d189411f031bc89d53f754b0aa27d197c93760d7b380465b7946ccde7701
7
- data.tar.gz: b1fe9bb935aabb37fe325ae6c72beac1b7f6b57413aeef375f51755fe621efa1180fcfc073db22f24069f9837b0705e23e9dcfadac971d3227e189ff0d7c6f5d
6
+ metadata.gz: 5aa9a8eaa7044715d30e8b8fa8349bb48e97f069550dc364c91a0d5249ca6a9e1c5602c9a32ededc6c0a6bbb951b356699f73b5d27318c441c52d958b2ac4430
7
+ data.tar.gz: ed599e02370d9ff9c3b45f6993020bacb80edacbb91845963d907b428447f79df8dec7c67f158a125a25d80adfdac27bcb6fb2e411a040bfdf18517bce973eae
@@ -17,10 +17,11 @@ module BlurhashImageHelper
17
17
  # size = source.variation.transformations[:resize]
18
18
  end
19
19
 
20
- blurhash = blob.metadata["blurhash"]
21
- size ||= "#{blob.metadata["width"]}x#{blob.metadata["height"]}"
20
+ blurhash = blob&.metadata&.fetch("blurhash", nil)
22
21
 
23
22
  if !!blurhash
23
+ size ||= "#{blob.metadata["width"]}x#{blob.metadata["height"]}"
24
+
24
25
  options[:loading] = "lazy"
25
26
  options[:size] = size
26
27
 
@@ -13,13 +13,15 @@ module BlurhashImageHelper
13
13
  blob = source.blob
14
14
  when ActiveStorage::VariantWithRecord
15
15
  blob = source.blob
16
- size = source.variation.transformations[:resize]
16
+ # dimensions of the transformation need not represent the actual aspect ratio, like in `resize_to_fit`
17
+ # size = source.variation.transformations[:resize]
17
18
  end
18
19
 
19
- blurhash = blob.metadata["blurhash"]
20
- size ||= "#{blob.metadata["width"]}x#{blob.metadata["height"]}"
20
+ blurhash = blob&.metadata["blurhash"]
21
21
 
22
22
  if !!blurhash
23
+ size ||= "#{blob.metadata["width"]}x#{blob.metadata["height"]}"
24
+
23
25
  options[:loading] = "lazy"
24
26
  options[:size] = size
25
27
 
@@ -22,7 +22,7 @@ module ActiveStorage
22
22
  end
23
23
 
24
24
  def pixels
25
- @thumbnail.to_a.flatten
25
+ @thumbnail&.to_a&.flatten || []
26
26
  end
27
27
  end
28
28
  end
@@ -17,7 +17,7 @@ module ActiveStorage
17
17
  when 3
18
18
  @thumbnail
19
19
  else
20
- @thumbnail.extract_band(0, n: 3)
20
+ @thumbnail&.extract_band(0, n: 3)
21
21
  end
22
22
  end
23
23
 
@@ -1,5 +1,5 @@
1
1
  module ActiveStorage
2
2
  module Blurhash
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveStorage
2
2
  module Blurhash
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage-blurhash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch