Jump to content

getting $user last image


Manaus
 Share

Recommended Posts

Hello,

I'm trying to display the just uploaded image on the page, but I can't make it work.

This is the code

<img src='<?= $user->avatar->last->getThumb('thumbnail') ?>' alt='' />

I get a Call to a member function getThumb() on a non-object error.

Still the image is uploaded correctly, as I can see from the admin...

Instead if I load the page as a usual Get, I can see the image correctly.

This is the code I use for uploading the image...

	$user->of(false);
	$user->avatar->deleteAll();

	$a = new WireUpload('avatar');
	$a->setMaxFiles(1);
	$a->setOverwrite(true);
	$a->setDestinationPath($user->avatar->path());
	$a->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif'));

	foreach ($a->execute() as $files) {
		$user->avatar->add($files); 
	}

	$user->save();
	$user->of(true);

Thanks for any suggestion

Link to comment
Share on other sites

What is your setting for the amount of max images in your avatar field? If it is set to "1", then (if outputformatting is on)

Pw returns directly the PageImage object - NOT the PageArray.

So you could try this:

$user->avatar->getThumb('thumbnail');
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...