我使用这个微消息系统脚本,我想添加一个头像到它,然而,我缺乏PHP知识使这一点很难。
我用来显示头像的代码是:
userphoto_thumbnail($user_info, $before = '', $after = '', $attributes = array(width => '40', height => '40'), $default_src = '')我想把这个头像注入到消息脚本的这一部分(在循环中):
$r = $r . '<tr id="wpam-reply-' . $post->post_ID . '-' . $count . '" ' . $style . '>';
$r = $r . '<td style="padding:10px 0 10px 10px; width:40px;"><span title="' . $user_info->display_name . ' (' . $user_info->user_login . ')">' . userphoto_thumbnail($user_info, $before = '', $after = '', $attributes = array(width => '40', height => '40'), $default_src = '') . '</span></td>';
$r = $r . '<td>' . wpam_get_message($reply, $user_info, $options, 2) . '</td>';
$r = $r . '</tr>';如果您查看第二行,您将看到我是如何在那里添加它的。但是,这不会将头像返回到它应该在的位置。它出现在其他一切事物之外。也许是因为它返回的是字符串而不是数据?我不确定,因为我只是刚刚熟悉PHP术语。
我确定我没有正确地将头像代码添加到脚本中,您能提供帮助吗?
编辑:为了澄清,在超文本标记语言的输出中,头像图像出现在表格之外,而实际上它们应该在<td style="padding:10px 0 10px 10px; width:40px;">标记内。
发布于 2012-09-10 22:43:45
从documentation上看,看起来像是userphoto_thumbnails打印出了图像。您正在尝试将其连接起来。当你调用它时,它是在你创建字符串的时候打印出来的,所以它出现在错误的位置。
试试这个:
echo '<tr id="wpam-reply-' . $post->post_ID . '-' . $count . '" ' . $style . '>';
echo '<td style="padding:10px 0 10px 10px; width:40px;"><span title="' . $user_info->display_name . ' (' . $user_info->user_login . ')">';
userphoto_thumbnail($user_info, $before = '', $after = '', $attributes = array(width => '40', height => '40'), $default_src = '');
echo . '</span></td>';
echo '<td>' . wpam_get_message($reply, $user_info, $options, 2) . '</td>';
echo '</tr>';这将把所有内容打印到正确的位置,尽管您不再创建$r变量。
https://stackoverflow.com/questions/12353574
复制相似问题