1

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
4

1 に答える 1

2
 <%= image_tag "http://graph.facebook.com/#{current_user.uid}/picture?type=large" %>

これは私が使用したソリューションでした

于 2012-10-09T09:02:20.940 に答える