Where is the user's picture stored in Drupal 7

2019-05-11 10:51发布

I'm using a SelectQuery object to retrieve and display a list of users, but I don't know where to get the user's picture from.

The users table has a column called picture, but the data in there is just an integer. Is the picture stored in a blob field somewhere or is there a link to the picture in another table?

2条回答
淡お忘
2楼-- · 2019-05-11 11:14

Hello please user this code :

<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$uid = 99;
$account = user_load($uid);
// get image information
$image_path = 'public://avatars/upload/b8f1e69e83aa12cdd3d2babfbcd1fe27_4.gif';
$image_info = image_get_info($image_path);
?>

For get user avatar uri;

Thanks, JAY

查看更多
何必那么认真
3楼-- · 2019-05-11 11:24

The image file itself is stored (usually) somewhere in /sites/default/files. The reference to that image is stored in the file_managed table, the picture column in the users table contains the fid (file id) of the picture.

You can load the file object like this:

$file = file_load($fid);

And get the output for the image like this:

$image = theme('image', array('path' => $file->uri, 'alt' => 'Alt text'));
查看更多
登录 后发表回答