Skip to content

Instantly share code, notes, and snippets.

@ewoodh2o
Forked from johnmaxwell/gist:959665
Created May 6, 2011 20:30
Show Gist options
  • Save ewoodh2o/959724 to your computer and use it in GitHub Desktop.
Save ewoodh2o/959724 to your computer and use it in GitHub Desktop.
def upload_sizing
result = {}
if uploads_enabled?
dims = lambda {|size| send("upload#{size}_width?") && send("upload#{size}_width?") ?
{ width: send("upload#{size}_width"), height: send("upload#{size}_width") } : nil
}
{:enable_images? => :resize, :enable_videos? => :encode}.each do |method, result_key|
['', '_thumb'].each do |size|
result["#{result_key}#{size}".to_sym] = dims.call(size) if dims.call(size)
end if send(method)
end
end
result[:export] = { use: result.stringify_keys.keys }
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment