Skip to content

Instantly share code, notes, and snippets.

@adorr
Created May 6, 2011 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adorr/959582 to your computer and use it in GitHub Desktop.
Save adorr/959582 to your computer and use it in GitHub Desktop.
def upload_sizing
result = {:export => {use: []}}
return result unless self.uploads_enabled?
if self.upload_width? && self.upload_height?
if self.enable_images?
result[:resize] = {
width: self.upload_width,
height: self.upload_height
}
end
if self.enable_videos?
result[:encode] = {
width: self.upload_width,
height: self.upload_height
}
end
end
if self.upload_thumb_width? && self.upload_thumb_height?
if self.enable_images?
result[:resize_thumb] = {
width: self.upload_thumb_width,
height: self.upload_thumb_height
}
end
if self.enable_videos?
result[:encode_thumb] = {
width: self.upload_thumb_width,
height: self.upload_thumb_height
}
end
end
result[:export][:use].push("resize").push("resize_thumb") if self.enable_images?
result[:export][:use].push("encode").push("encode_thumb") if self.enable_videos?
result
end
@akasper
Copy link

akasper commented May 6, 2011

@johnmaxwell
Copy link

@akasper
Copy link

akasper commented May 6, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment