「Drupalメモ」の版間の差分

提供:Software Development Memo
ナビゲーションに移動 検索に移動
1行目: 1行目:
[[Category:Tips]][[Category:CMS]]
[[Category:Tips]][[Category:CMS]]
== アバターの画像URLを絶対URLから相対URLに変更する ==
Drupalのアバターの画像URLは絶対URLとなります。これは、リバースプロキシ等のURLを変換してアクセスする環境において、画像がデットリンクとなることがあります。相対URLに変更するためには、「user.module」の「template_preprocess_user_picture」関数を以下とします。(変更箇所は15行目)
<source lang="php" line>
/**
* Process variables for user-picture.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-picture.tpl.php
*/
function template_preprocess_user_picture(&$variables) {
  $variables['picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account->picture) && file_exists($account->picture)) {
      // $picture = file_create_url($account->picture);
      $picture = file_create_url($account->picture);
    }
    else if (variable_get('user_picture_default', '')) {
      $picture = variable_get('user_picture_default', '');
    }
    if (isset($picture)) {
      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
      $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
      if (!empty($account->uid) && user_access('access user profiles')) {
        $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
        $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
      }
    }
  }
}
</source>
Drupalの拡張の作法に従っていないかもしれませんのでご注意ください。(あまり公式ドキュメントに目を通していないので)
動作環境
* バージョン : 6.20


== Proxyを使用して更新確認を行う ==
== Proxyを使用して更新確認を行う ==

2012年11月12日 (月) 14:58時点における版


Proxyを使用して更新確認を行う

「includes/common.inc」を以下のように変更します。(バージョン6.15を使用)

457,460c457
<       // --- mod start
<       //$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
<       $fp = @fsockopen('<WWW.XXX.YYY.ZZZ>', '<PORT>'); // 第1引数:ホスト名, 第2引数:ポート番号
<       // --- mod end
---
>       $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
533,537c530,531
<   // --- mod start
<   // $request = $method .' '. $path ." HTTP/1.0\r\n";
<   // $request .= implode("\r\n", $defaults);
<   $request = "$method ".$uri['scheme']."://".$uri['host'].$path." HTTP/1.1\r\n";
<   // --- mod end
---
>   $request = $method .' '. $path ." HTTP/1.0\r\n";
>   $request .= implode("\r\n", $defaults);


更新履歴