Skip Navigation

[Resolved] Image display using types_render_usermeta on single author page

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to display custom user image field using Types API or display types usermeta

Solution:
you can use same attributes for "types_render_usermeta()" function.

types_render_usermeta( "my-image", array( "alt" => "blue bird", "width" => "300", "height" => "200", "proportional" => "true", user_id => "1" ) );

You can find proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/image-display-using-types_render_usermeta-on-single-author-page-2/#post-609189

Relevant Documentation:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#image
=> https://toolset.com/documentation/customizing-sites-using-php/creating-custom-user-profiles/

This support ticket is created 6 years, 10 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by jasonH-5 6 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#609054

Hello- I opened this ticket a few days ago but the issue has not been solved. I initially thought I had solved it...

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.

#609189

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you can use same attributes for "types_render_usermeta()" function.

For example:

types_render_usermeta( "my-image", array( "alt" => "blue bird", "width" => "300", "height" => "200", "proportional" => "true", user_id => "1" ) );

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#image
=> https://toolset.com/documentation/customizing-sites-using-php/creating-custom-user-profiles/

#609283

Hello Minish, Thank you for your help. I see the ID goes inside the main array which should have been obvious. Thank you again for your help