Skip to content

Commit 8b7658d

Browse files
committed
fix(Asset Upload): use new syntax for ImageProcessing library; ignore host_alias if missing
1 parent 90c9e21 commit 8b7658d

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
cortex-plugins-core (3.0.0)
4+
cortex-plugins-core (3.1.0)
55
aws-sdk-s3 (~> 1.17)
66
cells (~> 4.1)
77
cells-haml (~> 0.0)
@@ -63,7 +63,7 @@ GEM
6363
arel (9.0.0)
6464
aws-eventstream (1.0.1)
6565
aws-partitions (1.97.0)
66-
aws-sdk-core (3.23.0)
66+
aws-sdk-core (3.24.0)
6767
aws-eventstream (~> 1.0)
6868
aws-partitions (~> 1.0)
6969
aws-sigv4 (~> 1.0)
@@ -171,7 +171,7 @@ GEM
171171
rake (>= 0.8.7)
172172
thor (>= 0.18.1, < 2.0)
173173
rake (12.3.1)
174-
ruby-vips (2.0.12)
174+
ruby-vips (2.0.13)
175175
ffi (~> 1.9)
176176
shrine (2.11.0)
177177
down (~> 4.1)

app/models/asset_field_type.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ def attacher
8888
end
8989

9090
def host_alias
91-
metadata&.[](:storage)&.[](:host_alias)
91+
metadata&.[](:storage)&.[](:host_alias).presence || nil
9292
end
9393

9494
def versions_data
95+
# TODO: Create Dry::Type for this object
9596
asset.transform_values do |version|
9697
{
9798
id: version.id,

app/uploaders/asset_uploader.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class AssetUploader < Shrine
3434
if image?(io)
3535
image_optim = image_optim_for(context[:config][:metadata][:image_optim_config])
3636
versions.merge!(context[:config][:metadata][:versions].transform_values do |version|
37-
processed_version = send("#{version[:process][:method]}!", io.download, *version[:process][:config].values)
37+
processed_version = ImageProcessing::MiniMagick
38+
.source(io.download)
39+
.send("#{version[:process][:method]}!", *version[:process][:config].values)
3840
optimize_image!(processed_version, image_optim) # TODO: per-version image_optim_config
3941
end)
4042
end

lib/cortex/plugins/core/engine.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require 'jsonb_accessor'
22
require 'react_on_rails'
3+
require 'mimemagic'
4+
require 'hashie'
35

46
module Cortex
57
module Plugins

0 commit comments

Comments
 (0)