Skip Navigation

[Gelöst] Image display using types_render_usermeta on single author page

This support ticket is created vor 6 Jahren, 10 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von jasonH-5 vor 6 Jahren, 10 Monaten.

Author
Artikel
#608305

Hello-

I have successfully set-up a single author page using author.php which displays custom user fields. One of the items displayed is the users profile image. In order to display this image I have used the following code used from a combination of Toolset support threads and the wordpress.org support forums.

<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
echo types_render_usermeta( 'rabbit-profile-photo', array( "user_id" => $curauth->ID ) );
?>

This successfully displays the custom user meta field I created which an image upload field for the profile photo.

The issue is that I need to display specific cropped dimensions. Because I am rendering the image with 50% border-radius in CSS to create the image a circle. For the types_render_field I use the following from your documentation:

types_render_field( "my-image", array( "alt" => "Profile Photo", "width" => "500", "height" => "500", "resize" => "crop" ) )

How do I display this using types_render_usermeta?

Thank you for your help.

#608310

Going to answer my own question here:

<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
echo types_render_usermeta( 'rabbit-profile-photo', array( "alt" => "Rabbit Profile Photo", "width" => "500", "height" => "500", "resize" => "crop"), array( "user_id" => $curauth->ID ));
?>

This worked fine.