Juergen Posted April 29, 2015 Posted April 29, 2015 Hello @ all, I added a profil image to the user template in the backend. Unfortunately I am not able to resize the image in frontend. $img = $image->size($x, $y) This function doesnt work for images which are stored in the user template. Here is the complete code $userimage = $user->userimage; if ($userimage){ $options = array( 'quality' => 90, 'upscaling' => false, 'cropping' => 'north' ); $img = $userimage->size(80, 100, $options); echo '<img src="'.$img.'"/> } I always got this error: Error: Exception: Method Pageimages::size does not exist or is not callable in this context (in /home/.sites/24/site1275/web/wire/core/Wire.php line 350) Imagefield setup: Number of allowed images = 1 Format = auto Is it not possible if I call an image from the user? Thanks for your answeres
Nico Knoll Posted April 29, 2015 Posted April 29, 2015 Could you do a var_dump($user->userimage); and check if it's a single Image object?
LostKobrakai Posted April 29, 2015 Posted April 29, 2015 Seems like you're still getting an array of images, even though it should just return the single image with this field settings. Try using "$user->userimage->first()" or using Format = single for a temp. fix. Additionally I think you need to use "$img->url" in the echo line. The field not returning a Pageimage, but Pageimages seems to be a bug. It would be nice if you could report this on Github. Could you do a var_dump($user->userimage); and check if it's a Image object? "Method Pageimages::size" The error says enough. 1
Juergen Posted April 29, 2015 Author Posted April 29, 2015 $userimage = $user->userimage->first() and $userimage = $user->userimage return both the same array with var_dump: object(Pageimages)#656 (2) { ["count"]=> int(1) ["items"]=> array(1) { ["bewerbungklein-1.jpg"]=> string(20) "bewerbungklein-1.jpg" } } Strange behaviour because if the image is in a page template like $pageimage = $page->userimage this will work.
Juergen Posted April 29, 2015 Author Posted April 29, 2015 I have changed the image settings from "auto" to "single element (null if empty)" and now it works. Thanks for your efforts
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