Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cached file first to open image with MiniMagic #2299

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/carrierwave/processing/mini_magick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,8 @@ def dimension_from(value)
end

def mini_magick_image
if url
::MiniMagick::Image.open(url)
else
::MiniMagick::Image.open(current_path)
end
img = cached? ? full_cached_path : url || current_path
::MiniMagick::Image.open(img)
end

end # MiniMagick
Expand Down
11 changes: 11 additions & 0 deletions lib/carrierwave/uploader/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ def cache_path(for_file=full_filename(original_filename))
File.join(*[cache_dir, @cache_id, for_file].compact)
end

##
# Gets the full path where the cached file is stored
#
# === Returns
#
# [String] the full cached path
#
def full_cached_path
File.join(root, cache_path)
end

private

def workfile_path(for_file=original_filename)
Expand Down