Skip to content

Commit

Permalink
fix issue #238 + File.exists? -> File.exist?
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Aug 30, 2024
1 parent ee59720 commit 4386db6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PATH
RedCloth (~> 4.3.2)
bcrypt (~> 3.1.11)
chronic (~> 0.10.2)
dragonfly (>= 1.2, < 1.5)
dragonfly (~> 1.4.0)
duktape (~> 2.0.1.1)
execjs (~> 2.9.1)
httparty (~> 0.21.0)
Expand Down
8 changes: 6 additions & 2 deletions lib/locomotive/steam/initializers/dragonfly.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'dragonfly'

module Locomotive
module Steam
module Initializers

class Dragonfly

def run
require 'dragonfly'

# need to be called outside of the configure method
imagemagick_commands = find_imagemagick_commands

Expand All @@ -15,6 +15,10 @@ def run
plugin :imagemagick, imagemagick_commands
end

processor :convert do |content, args|
::Dragonfly::ImageMagick::Commands.convert(content, args)
end

verify_urls true

secret Locomotive::Steam.configuration.image_resizer_secret
Expand Down
13 changes: 9 additions & 4 deletions lib/locomotive/steam/services/image_resizer_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class ImageResizerService

attr_accessor_initialize :resizer, :asset_path

def resize(source, geometry, convert = "")
def resize(source, geometry, convert_args = "")
return get_url_or_path(source) if disabled? || geometry.blank?

if file = fetch_file(source)
transformed_file = file.thumb(geometry)
transformed_file = transformed_file.convert(convert) if !convert.blank?
transformed_file.url
job = file.thumb(geometry)
job = image_magick_convert(job, convert_args)
job.url
else
Locomotive::Common::Logger.error "Unable to resize on the fly: #{source.inspect}"
nil
Expand Down Expand Up @@ -47,6 +47,11 @@ def get_url_or_path(source)
value.strip if value
end

def image_magick_convert(job, options = '')
return job if options.blank?
job.process(:convert, options)
end

end

end
Expand Down
2 changes: 1 addition & 1 deletion locomotivecms_steam.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'rack-cache', '>= 1.7', '< 2'
spec.add_dependency 'rack-session', '~> 2.0.0'
spec.add_dependency 'rack_csrf', '~> 2.6.0'
spec.add_dependency 'dragonfly', '>= 1.2', '< 1.5'
spec.add_dependency 'dragonfly', '~> 1.4.0'
spec.add_dependency 'moneta', '~> 1.6.0'

spec.add_dependency 'execjs', '~> 2.9.1'
Expand Down

0 comments on commit 4386db6

Please sign in to comment.