2015-01-09 57 views
0

我正在使用Omniauth-Twitter gem對用戶進行身份驗證並顯示其個人資料圖像。當我嘗試通過link_to方法在我的users#show視圖中顯示完整尺寸的用戶配置文件圖像時,圖像被調整爲41x41px。有什麼辦法獲得標準的圖片網址(256x256px)?Omniauth-Twitter - 原始配置文件圖像

omniauth.rb初始化有默認圖像尺寸設置爲original,如下所示:

Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :twitter, "...", "..." 
    { 
     ... 

     :secure_image_url => 'true', 
     :image_size => 'original', 

     ... 
    } 
end 

和我User模型追加Twitter圖片網址列在Users表所示:

class User < ActiveRecord::Base 

    def self.from_omniauth(auth) 
     where(provider: auth.provider, uid: auth.uid).first_or_create do |user| 
      ... 
      user.image_url = auth.info.image 
      ... 
     end 

    end 

end 

我試過的:

  1. 刪除:image_size對從數據散列
  2. 傳遞width:height:性質的link_to
  3. 更改image_size鍵的值 .extra.raw_info.profile_image_url

回答

0

我找到了解決辦法可能會在違反強大慣例配置原理:

刪除任何確定圖像大小的調用(即從URL字符串中使用.gsub!這樣的方法:

"profile_image_path_normal.jpg".gsub!("_normal","") #replaces "_normal" with nothing 

很想聽聽其他建議。