Skip to content

Instantly share code, notes, and snippets.

@johnmaxwell
Forked from adorr/gist:959582
Created May 6, 2011 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnmaxwell/959665 to your computer and use it in GitHub Desktop.
Save johnmaxwell/959665 to your computer and use it in GitHub Desktop.
def upload_sizing
result = {:export => {use: []}}
if uploads_enabled?
dims = (upload_width? && upload_height?) ? { width: upload_width, height: upload_height } : nil
dims_thumb = (upload_thumb_width? && upload_thumb_height?) ? { width: upload_thumb_width, height: upload_thumb_height } : nil
if enable_images?
if dims
result[:resize] = dims
result[:export][:use] << "resize"
end
if dims_thumb
result[:resize_thumb] = dims_thumb
result[:export][:use] << "resize_thumb"
end
end
if enable_videos?
if dims
result[:encode] = dims
result[:export][:use] << "encode"
end
if dims_thumb
result[:encode_thumb] = dims_thumb
result[:export][:use] << "encode_thumb"
end
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment