【问题标题】:Resize facebook profile picture调整 Facebook 个人资料图片的大小
【发布时间】:2012-10-07 23:31:47
【问题描述】:

我正在尝试将 Facebook 个人资料图片的大小调整为大。我知道为了使个人资料图片变大,我必须输入 http://graph.facebook.com/id/picture?type=large

从我目前在下面的代码中得到的 http://graph.facebook.com/id/picture?type=square

如何更改用户信息以使个人资料图片的图像变大,并且对每个用户的个人资料图片都进行此操作。 (注意:我不希望它在其他任何地方调整大小)。

用户信息

<h1 class="twshadow">
  <%= current_user.name %>
  **<%= image_tag current_user.image %>**
</h1>
<span>
  <%= link_to "View my Profile", current_user %>
</span>

USER.RB

class User < ActiveRecord::Base
  attr_accessible :name, :oauth_expires_at, :oauth_token, :provider, :uid, :email, :image

  def self.from_omniauth(auth)
    where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
      user.provider = auth.provider
      user.uid = auth.uid
      user.name = auth.info.name
      user.email = auth.info.email
      user.image = auth.info.image
      user.oauth_token = auth.credentials.token
      user.oauth_expires_at = Time.at(auth.credentials.expires_at)
      user.save!
    end
  end
end

数据库

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :provider
      t.string :uid
      t.string :name
      t.string :email
      t.string :image
      t.string :oauth_token
      t.datetime :oauth_expires_at

      t.timestamps
    end
  end
end

class ApplicationController < ActionController::Base
  protect_from_forgery

private

  def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
  end
  helper_method :current_user
end

【问题讨论】:

  • graph.facebook.com/#{current_user.uid}/picture?type=large" %>

标签: ruby-on-rails facebook facebook-graph-api ruby-on-rails-3.2 omniauth


【解决方案1】:
 <%= image_tag "http://graph.facebook.com/#{current_user.uid}/picture?type=large" %>

这是我使用的解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    相关资源
    最近更新 更多