Skip to content
Merged
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
6 changes: 5 additions & 1 deletion app/helpers/filepicker_rails/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def filepicker_image_tag(url, image_options={}, image_tag_options={})
#
# - `:cache` - Specifies if the image should be cached or not.
#
# - `:compress` - You can take advantage of Filepicker's image compression which utilizes JPEGtran and OptiPNG.
# The value for this parameter is boolean. If you want to compress your image then the parameter
# is compress:true. Compression is off/false by default.
#
# #### Examples
#
# filepicker_image_url @user.filepicker_url, w: 160, h: 160, fit: 'clip'
Expand All @@ -177,7 +181,7 @@ class FilepickerImageUrl
CONVERT_OPTIONS = [:w, :h, :fit, :align, :rotate, :crop, :format,
:quality, :watermark, :watersize, :waterposition,
:crop_first]
VALID_OPTIONS = CONVERT_OPTIONS + [:cache]
VALID_OPTIONS = CONVERT_OPTIONS + [:cache, :compress]

def initialize(url, options = {})
@url, @options = url, options
Expand Down
12 changes: 12 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ def build_link(options = {})
end
end

describe 'compress' do

it "have correct url with 'compress' only" do
expect(filepicker_image_url("foo", compress: true)).to eq('foo?compress=true')
end

it "have correct url with 'compress' and convert option" do
url = 'foo/convert?align=faces&compress=true'
expect(filepicker_image_url("foo", compress: true, align: 'faces')).to eq(url)
end
end

describe "when convert options is already in the url" do

it "merges the options into the query params" do
Expand Down