Manaus Posted November 11, 2013 Share Posted November 11, 2013 Hello, I added a crop image field in the user template, and set the field to accepting 1 file only. I upload the image via the front end using these values: $a->setMaxFiles(1); $a->setOverwrite(true); Now, if I upload an image via the back end or the front end, the image field keeps many images. This resolves in a code trouble: if I try to print $page->createdUser->image->getThumb('micro') I get a string: the first image, but I need the last one. Btw printing $user->image I get an array, but it’s not what I need. Tried of course $page->createdUser->image->last()->getThumb('micro'), but returns an error "Pageimage::last does not exist or is not callable in this context"Thanks for any suggestion...! Link to comment Share on other sites More sharing options...
adrian Posted November 12, 2013 Share Posted November 12, 2013 I think you might need to do something like this: $users->get($page->createdUser->name)->image->last->getThumb('micro'); You need to get the name of the createdUser of the current page and get that user's fields from $users. As for the issue of keeping multiple images - those settings won't work on the front end - you need to delete all existing images before uploading. See this post from Ryan: http://processwire.com/talk/topic/4267-creating-new-page-in-combination-with-a-file-upload/?p=41876 Hope that helps. 1 Link to comment Share on other sites More sharing options...
Manaus Posted December 2, 2013 Author Share Posted December 2, 2013 Thanks Adrian. I can't find last in the documentation, just last() (which is behaving differently, as it seems) Any hint where I can look? Thanks! Link to comment Share on other sites More sharing options...
adrian Posted December 2, 2013 Share Posted December 2, 2013 Manaus - my mistake, it should be last(). Please let us know what happens when you try: $users->get($page->createdUser->name)->image->last()->getThumb('micro'); Link to comment Share on other sites More sharing options...
Soma Posted December 2, 2013 Share Posted December 2, 2013 They are the same. Like with first, child or children. Both version can be used. They're for convenience. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now