izi_lightup 1.0.12 → 1.0.13
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/lib/izi_lightup/smart_picture.rb +16 -1
- data/lib/izi_lightup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a9caf0a357d64fe6ee03a00bfb69fdb37fd2663ffb8473484f6bf00b473e7da
|
4
|
+
data.tar.gz: 752bf51570ee50e41e316cd1c901af0e5a5ad0c7600a1e56870e668d98261a59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 121307a969169c1673f5dc2a1c657ce36a84e3de6a7ab43d40e2f57d300cf82438f0e3e1775cd4cd5254d1e5ccda8eed692ef749fdf6c8ff663d9bc05316955c
|
7
|
+
data.tar.gz: 44c7675d48b3ad3fa1296c3486162f12eb6882bd2ffec6de668553b43c4755e97f6ffab5d10e8fb7557596a27d44b2d796810f665dc7b2b2b5249f0650a486f3
|
@@ -22,7 +22,9 @@ module IziLightup
|
|
22
22
|
next unless version&.file&.exists? && version&.url&.present?
|
23
23
|
|
24
24
|
url = version.url
|
25
|
-
|
25
|
+
dimensions = safe_dimentions(item, version)
|
26
|
+
params.merge!(dimensions) if dimensions.present?
|
27
|
+
|
26
28
|
return image_tag(url, params) unless block_given?
|
27
29
|
|
28
30
|
yield(url, params)
|
@@ -35,6 +37,19 @@ module IziLightup
|
|
35
37
|
|
36
38
|
private
|
37
39
|
|
40
|
+
def safe_dimentions(item, version)
|
41
|
+
dimensions = nil
|
42
|
+
begin
|
43
|
+
dimensions = version.dimensions
|
44
|
+
rescue MiniMagick::Error => _e
|
45
|
+
dimensions = [item&.width, item&.height].compact
|
46
|
+
end
|
47
|
+
|
48
|
+
return {} if dimensions.blank?
|
49
|
+
|
50
|
+
%i[width height].zip(dimensions).to_h
|
51
|
+
end
|
52
|
+
|
38
53
|
def fetch_items(object, fields)
|
39
54
|
Array.wrap(fields).map do |name|
|
40
55
|
object.respond_to?(name) ? object.public_send(name) : nil
|
data/lib/izi_lightup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: izi_lightup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IzikAJ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Utils to speed up page load by using critical css &
|