alchemy_cloudinary 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/alchemy/picture/cloudinary_url.rb +64 -0
- data/lib/alchemy_cloudinary/engine.rb +2 -2
- data/lib/alchemy_cloudinary/{create_picture_thumb.rb → store_picture_thumb.rb} +2 -2
- data/lib/alchemy_cloudinary/version.rb +1 -1
- data/lib/alchemy_cloudinary.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25c385dedb6812dfc76af611195e5b2ac03f6a430378e1ed074636e769c77dee
|
4
|
+
data.tar.gz: b3b0ff2d9ae499ed9a90b7d0b6f47151f6ca502275e73ec43c85016b0e8f6ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5cea91301b14e76b35c491f1923d168127cc178ced68d9f18b7dc4a045ddc2ce9abbf96416fdc192b0ac987b996e7bbbda44d9ee43e4bf56cc6195ff2c2c74e
|
7
|
+
data.tar.gz: 1b353d12759778bd3aee6fc9969588e858e889e8ee83e4a6811390453b3a825a8f70ae24eb70fe340edc743223acf654d540a8a9c7be3eee6dc2b4bd84c26d63
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "alchemy/picture"
|
4
|
+
|
5
|
+
module Alchemy
|
6
|
+
class Picture < BaseRecord
|
7
|
+
class CloudinaryUrl < Url
|
8
|
+
def call(params = {})
|
9
|
+
@options = variant.instance_variable_get(:@options)
|
10
|
+
|
11
|
+
variant.picture.image_file.remote_url(
|
12
|
+
transformation: transformations,
|
13
|
+
secure: true,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :options
|
20
|
+
|
21
|
+
def transformations
|
22
|
+
[crop_transformation, resize_transformation].compact
|
23
|
+
end
|
24
|
+
|
25
|
+
def crop_transformation
|
26
|
+
if options[:crop] && options[:crop_from].present?
|
27
|
+
{
|
28
|
+
crop: "crop",
|
29
|
+
gravity: "xy_center",
|
30
|
+
x: crop_coordinates[:x],
|
31
|
+
y: crop_coordinates[:y],
|
32
|
+
size: options[:crop_size],
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def resize_transformation
|
38
|
+
if options[:size]
|
39
|
+
{
|
40
|
+
crop: crop_mode,
|
41
|
+
size: options[:size],
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def crop_mode
|
47
|
+
if options[:crop]
|
48
|
+
"fill"
|
49
|
+
else
|
50
|
+
options[:upsample] ? "fit" : "limit"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def crop_coordinates
|
55
|
+
x, y = options[:crop_from].to_s.split("x")
|
56
|
+
size_x, size_y = options[:crop_size].to_s.split("x")
|
57
|
+
{
|
58
|
+
x: (x.to_i + size_x.to_f / 2).round,
|
59
|
+
y: (y.to_i + size_y.to_f / 2).round,
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -13,9 +13,9 @@ module AlchemyCloudinary
|
|
13
13
|
|
14
14
|
config.to_prepare do
|
15
15
|
require_dependency "alchemy/picture/cloudinary_url"
|
16
|
-
require_dependency "alchemy_cloudinary/
|
16
|
+
require_dependency "alchemy_cloudinary/store_picture_thumb"
|
17
17
|
Alchemy::Picture.url_class = Alchemy::Picture::CloudinaryUrl
|
18
|
-
Alchemy::PictureThumb.
|
18
|
+
Alchemy::PictureThumb.storage_class = AlchemyCloudinary::StorePictureThumb
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module AlchemyCloudinary
|
2
|
-
class
|
2
|
+
class StorePictureThumb
|
3
3
|
def self.call(*)
|
4
|
-
# make this noop, because we do not want to
|
4
|
+
# make this noop, because we do not want to store thumbnails,
|
5
5
|
# since Cloudinary renders image thumbnails on demand
|
6
6
|
end
|
7
7
|
end
|
data/lib/alchemy_cloudinary.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '7.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '7.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: cloudinary
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,10 +53,11 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- MIT-LICENSE
|
55
55
|
- README.md
|
56
|
+
- app/models/alchemy/picture/cloudinary_url.rb
|
56
57
|
- lib/alchemy_cloudinary.rb
|
57
|
-
- lib/alchemy_cloudinary/create_picture_thumb.rb
|
58
58
|
- lib/alchemy_cloudinary/dragonfly_data_store.rb
|
59
59
|
- lib/alchemy_cloudinary/engine.rb
|
60
|
+
- lib/alchemy_cloudinary/store_picture_thumb.rb
|
60
61
|
- lib/alchemy_cloudinary/version.rb
|
61
62
|
homepage: https://alchemy-cms.com
|
62
63
|
licenses:
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.4.17
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: AlchemyCMS Cloudinary Integration.
|