【问题标题】:Where is the user's picture stored in Drupal 7?用户的图片在 Drupal 7 中存储在哪里?
【发布时间】:2011-12-08 14:59:45
【问题描述】:

我正在使用 SelectQuery 对象来检索和显示用户列表,但我不知道从哪里获取用户的图片。

users表有一列叫做picture,但是里面的数据只是一个整数。图片是存储在某处的 blob 字段中,还是有指向另一个表中图片的链接?

【问题讨论】:

    标签: php drupal drupal-7


    【解决方案1】:

    图像文件本身(通常)存储在/sites/default/files 的某个位置。对该图像的引用存储在file_managed 表中,users 表中的picture 列包含图片的fid(文件ID)。

    你可以像这样加载文件对象:

    $file = file_load($fid);
    

    并像这样获取图像的输出:

    $image = theme('image', array('path' => $file->uri, 'alt' => 'Alt text'));
    

    【讨论】:

      【解决方案2】:

      您好,请使用此代码:

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

      获取用户头像uri;

      谢谢, 周杰伦

      【讨论】:

        猜你喜欢
        • 2010-12-01
        • 1970-01-01
        • 2012-05-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-13
        • 1970-01-01
        相关资源
        最近更新 更多