Php 用户注册-显示用户上传图像
我正在为我的Wordpress站点使用此插件: 例如,要显示用户选择的国家/地区-这是您可以使用的简单代码:-Php 用户注册-显示用户上传图像,php,html,wordpress,Php,Html,Wordpress,我正在为我的Wordpress站点使用此插件: 例如,要显示用户选择的国家/地区-这是您可以使用的简单代码:- <?php global $current_user; echo $current_user->user_registration_country; ?> 这将显示用户在注册时选择的国家/地区。我现在想显示他们上传的照片,因此我正在执行以下操作:- <?php global $current_user; echo $current_user->us
<?php global $current_user; echo $current_user->user_registration_country; ?>
这将显示用户在注册时选择的国家/地区。我现在想显示他们上传的照片,因此我正在执行以下操作:-
<?php global $current_user; echo $current_user->user_registration_upload_picture; ?>
但是,这只是在站点前端显示图像的ID
有人能帮我,在我如何可以转换ID显示图像的网址
谢谢大家! 您获得的ID可能是附件的ID。您可以使用
wp\u get\u attachment\u image\u src
查找图像信息,然后显示它:
$image_attributes = wp_get_attachment_image_src( $current_user->user_registration_upload_picture );
if ($image_attributes) : ?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
$image\u attributes=wp\u get\u attachment\u image\u src($current\u user->user\u registration\u upload\u picture);
如果($image\u属性):?>
“宽度=”“高度=”“/>
Try if(如果)能奏效。在询问之前,一定要先做一些适当的研究。在搜索类似“wordpress按id获取图像”的内容时,此链接是第一个点击的链接。这正是我要找的!谢谢@alexander!