alchemy-json_api 0.23.0 → 0.24.0

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: 286d51964dbcd1daa66ce3c6ab76c762c41929c65aa4c670bd5ab50e63761e06
4
- data.tar.gz: e1d00037b288b60f6a482773675a2926f317b01c2f82492ad6b9f8ee82defd0a
3
+ metadata.gz: 6c6090af6d711e4a909628207f0b5f7d916944c60a8482b5b7ff958a38633d73
4
+ data.tar.gz: 4e70e1de9b2ab1a68ce359c32973deac67a0965ade5021a7cf398ea29bf83a82
5
5
  SHA512:
6
- metadata.gz: dd1e2056c485b4de654de4196809f6c7b8e0cdbab027ceb814a7e8ab0e97ad8eb63fecd444caf21bc8aa9b46e1266716b3534ec07871769a42845d2b4220631b
7
- data.tar.gz: 8303041d11e09785397f318a7371965f85f54955df255fae99c1fd1b558258a2519bd208b5b6171e15945f57c64958ee33045ad2e9ca4f19b2da60266f06bfda
6
+ metadata.gz: 56d2a3623ad9e3a8585d5487f94f08c3d4a31f17a177f300252056eec68f5f4223eb86f32eca26238c5d52ecc6481a39d845b8082ea3d5cb4daec2fc25004a92
7
+ data.tar.gz: 30ca7d8ca1e07d9e924e395ee42c0d4cbf693180052a70f003ccd592267564c2e701aea50462f24f659aad8f39c687d42fa90f05da2633ce2c90a82228a9a3c0
@@ -33,6 +33,27 @@ module Alchemy
33
33
  }
34
34
  end
35
35
 
36
+ attribute :srcset do |essence|
37
+ essence.content.settings.fetch(:srcset, []).map do |src|
38
+ case src
39
+ when Hash
40
+ url = essence.picture_url(src)
41
+ size = src[:size]
42
+ else
43
+ url = essence.picture_url(size: src)
44
+ size = src
45
+ end
46
+ width, height = size.split("x", 2)
47
+
48
+ {
49
+ url: url,
50
+ desc: "#{width}w",
51
+ width: width,
52
+ height: height,
53
+ }
54
+ end
55
+ end
56
+
36
57
  attribute :image_name do |essence|
37
58
  essence.picture.name
38
59
  end
@@ -39,6 +39,27 @@ module Alchemy
39
39
  }
40
40
  end
41
41
 
42
+ attribute :srcset do |ingredient|
43
+ ingredient.settings.fetch(:srcset, []).map do |src|
44
+ case src
45
+ when Hash
46
+ url = ingredient.picture_url(src)
47
+ size = src[:size]
48
+ else
49
+ url = ingredient.picture_url(size: src)
50
+ size = src
51
+ end
52
+ width, height = size.split("x", 2)
53
+
54
+ {
55
+ url: url,
56
+ desc: "#{width}w",
57
+ width: width,
58
+ height: height,
59
+ }
60
+ end
61
+ end
62
+
42
63
  attribute :image_name do |ingredient|
43
64
  ingredient.picture.name
44
65
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
3
  module JsonApi
4
- VERSION = "0.23.0"
4
+ VERSION = "0.24.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms