diff --git a/app/models/profile.rb b/app/models/profile.rb index f0b5865e2..47d709e84 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -56,17 +56,29 @@ class Profile < ActiveRecord::Base def image_url= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def image_url_small= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def image_url_medium= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def date= params @@ -86,4 +98,10 @@ class Profile < ActiveRecord::Base self.last_name.strip! if self.last_name end + private + def absolutify_local_url url + pod_url = AppConfig[:pod_url].dup + pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' + "#{pod_url}#{url}" + end end