在我的ruby On rails应用程序上,下面是header获取登录用户头像的代码片段:
<% if current_user.get_avatar_url.present? %>
<img src="<%= current_user.get_avatar_url %>" width="40" height = "40" class="img-circle profile-nav"/>
<% else %>
<img src="<%= asset_url('default-avatar.png') %>" width="40" height = "40" class="img-circle profile-nav"/>
<% end %>
controller
代码是:
def get_avatar_url
ret = ''
if self.profile.present? && self.profile.user_avatar.present?
ret = self.profile.user_avatar.avatar.thumb.url
end
if ret.blank? && self.provider == 'facebook'
ret = self.profile.avatar
end
ret = '/assets/default-avatar.png' if ret.blank?
ret
end
现在,当我检查页面时,我得到的结果如下:
<img src="http://graph.facebook.com/xxxxxxxxxx/picture?type=large" width="40" height="40" class="img-circle profile-nav">
现在会在控制台上引起混合内容警告
Mixed Content: The page at 'https://www.example.com/#_=_' was loaded over HTTPS, but requested an insecure image 'http://graph.facebook.com/xxxxxxx/picture?type=large'. This content should also be served over HTTPS.
我该如何解决这个问题?谢谢!!
发布于 2016-02-29 22:44:56
你在使用OmniAuth
吗?configuration显示了一个通过https加载的选项secure_image_url=true
。
https://stackoverflow.com/questions/35354889
复制相似问题