lib/mls.rb in mls-1.3.0 vs lib/mls.rb in mls-1.4.0

- old
+ new

@@ -68,18 +68,27 @@ included do belongs_to :avatar, :class_name => 'Photo' end def avatar_url(options={}) + options.reverse_merge!({ :style => nil, - :protocol => "http", :bg => nil, - :format => "jpg" + :protocol => 'https', + :format => "jpg", + :host => MLS.image_host }); - url_params = {s: options[:style], bg: options[:bg]}.select{ |k, v| v } - result = "#{options[:protocol]}://#{MLS.image_host}/#{avatar_digest}.#{options[:format]}" + url_params = { s: options[:style], bg: options[:bg] }.select{ |k, v| v } + + if options[:protocol] == :relative # Protocol Relative + result = '//' + else options[:protocol] + result = "#{options[:protocol]}://" + end + + result += "#{options[:host]}/#{avatar_digest}.#{options[:format]}" result += "?#{url_params.to_param}" if url_params.size > 0 result end