我使用Omniauth-Twitter创业板对用户进行身份验证并显示他们的配置文件图像。当我试图通过users#show方法在link_to视图中显示一个完整的用户配置文件图像时,图像将被调整为41x41px。有没有任何方法来获得一个标准的图像URL (256x256px)?
我的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我试过的是:
:image_size对width:和height:属性传递给link_toimage_size键的值更改为.extra.raw_info.profile_image_url发布于 2015-01-09 19:14:42
我发现的解决方案可能会违反强大的约定而不是配置原则:
删除任何确定图像大小的调用(即,通过使用.gsub!方法从URL字符串中删除,如下所示:
"profile_image_path_normal.jpg".gsub!("_normal","") #replaces "_normal" with nothing想听听其他建议。
https://stackoverflow.com/questions/27866924
复制相似问题