Jump to content

Display users image in comment


Falk
 Share

Recommended Posts

Hi all,

I'm trying to display a users profile image in a comments list and am not able to resize it.
The site is used as an intranet, so there are no guest-users allowed, all users are registered with a role "staff" and have a mandatory imagefield.

Using a multi-file image field, I tried the following code inside a function:

// who's the author?
$cite = $comment->getFormatted('cite');

// get the author and display profile picure (first in set)
$userImage = wire('users')->get($cite)->getUnformatted('images')->eq(0)->size(100,100)->url;

Without resizing, everything is fine:

// get the first image
$userImage = wire('users')->get($cite)->getUnformatted('images')->eq(0)->url;

// get the second image
$userImage = wire('users')->get($cite)->getUnformatted('images')->eq(1)->url;

works as expected.

I also tried a single-file field but without success either:
getting the original image URL works fine, resizing the image doesn’t.

 

Any ideas on that?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...