doutu4335 2012-08-17 21:04
浏览 21
已采纳

如何以编程方式打印用户的图片? 此代码无效

I’ve tried this so far in a Drupal 7 installation:

<?php print $user_picture; ?>
<?php print $user->picture ?>
<?php print $node->picture ?>

None of these snippets will get me the picture printed on the page.

I’m using Devel’s module, so I tried to get it to give me some hints. This is all I get:

picture (String, 1 characters ) 0
$...->picture

I’ve read that to print a variable you just print or echo it (echo $var1 for example). So why won’t this work? I’m adding this snippet inside my node.tpl.php template.

Any thoughts on this? Thank you for your insight!!

Update: This is the result of var_dump($user_picture):

string(0) "" 
  • 写回答

1条回答 默认 最新

  • dongyu9894 2012-08-17 23:10
    关注

    If all else fails:

    global $user;
    $image = theme('user_picture', array('account' => $user));
    print $image;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块