欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal节点或评论中显示用户头像

shiping1 的头像

Enabling user pictures (avatars)

Last updated April 8, 2012. Created by emmajane on May 7, 2005.
Edited by TapSkill, heather, add1sun, Heine. Log in to edit this page.

User pictures (or avatars) or pictures are part of the user.module, not the profile module.

Enable user pictures for Drupal 7

  1. Navigate to Configuration > People > Account settings.
  2. In the Personalization settings, select Enable user pictures.
  3. For Picture directory type pictures
  4. Under Picture display style, select thumbnail (you can change the size settings
  5. Click "Save configuration".

Next, ensure your user pictures display in your theme. These are enabled by default in Bartik, the default theme of Drupal 7 , so you may have to check this with any new theme you add.

  1. Go to Appearance and click "Settings" for the theme you have enabled as default.
  2. In the Toggle display settings, select User pictures in posts and/or User pictures in comments.
  3. Click "Save configuration".

Enable user pictures in Drupal 6 or earlier

  1. Navigate to the administration area for user module configuration page under Administer > User Management > User Settings. In Drupal 4.7 this screen is available from administer > settings > users.
  2. In the Pictures settings, for Picture support, select Enabled (Enable picture support.)
  3. You must set the directory where you want the images to be stored. Make sure the directory is created and make sure you have that directory has write permissions (that is, chmod to 755).
  4. Click "Save Configuration"

Once the pictures are enabled you must also make sure to change your settings to display them:

  1. Go to Administer > Site Building > Themes and click the "Configure" tab to change the setting for all of your themes. (To only make the change to one theme, click the "configure" link next to your-theme-name instead.)
  2. Check the boxes for "User pictures in posts" or/and "User pictures in comments" as appropriate.
  3. Make sure the check box for each content type you wish to use avatars is checked in the "Display post information on" section.
  4. Click "Save Configuration"

Displaying avatar images (in theme)

In the node.tpl.php, use "$node->picture" to get the URL of the image.

Moving images

The database stores the name of the directory you set in Step #3. If you want to move your images to a new directory you must complete the following steps:

  1. Update the directory identified in the previous section.
  2. Move existing images to the new directory.
  3. Update the database manually to use the new directory location. In Drupal 6.x the images are stored in the table users.
普通分类: