Where is the user's picture stored in Drupal 7?

▼魔方 西西 提交于 2019-12-22 10:38:28

问题


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?


回答1:


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'));



回答2:


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



来源:https://stackoverflow.com/questions/8432955/where-is-the-users-picture-stored-in-drupal-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!