Skip to content

Instantly share code, notes, and snippets.

@dinedal
Created May 6, 2011 20:34
Show Gist options
  • Save dinedal/959729 to your computer and use it in GitHub Desktop.
Save dinedal/959729 to your computer and use it in GitHub Desktop.
def upload_sizing
result = {}
size = {:width => self.upload_width, :height => self.upload_height}
thumb_size = {:width => self.upload_thumb_width, :height => self.upload_thumb_height}
keys = []
keys.push "resize" if self.enable_images?
keys.push "encode" if self.enable_videos?
keys.each do |key|
result[key.to_sym] = size if self.upload_width? && self.upload_height?
result["#{key}_thumb".to_sym] = thumb_size if self.upload_thumb_width? && self.upload_thumb_height?
end
result[:export][:use] = result.keys.collect { |key| key.to_s }
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment