Mats Posted January 20, 2014 Posted January 20, 2014 Hi! I'm using repeaters (lang_image) for images with multi language captions in a template. These pages are used in a page fieldtype. Everything works fine with the default language (swedish) but not when i switch to english. Then i get this: Error: Call to a member function size()... My code looks like this: foreach ($page->person as $pers) { echo "<img src='{$pers->lang_image->first()->images->size(300,300)->url}'>"; } Got this working, not sure how though since the code is the same as the one i tried yesterday. Forgot to change language. Still doesn't work.
ryan Posted January 24, 2014 Posted January 24, 2014 When you get that error message "call to member function size()", what is 'images' ? Is it NULL or is it a single image field that has become a multi-image field? To tell, you could try doing a var_dump() on it or this: $images = $pers->lang_image->first()->images; echo "images is: "; if(is_null($images)) echo "NULL"; else if(is_object($images)) echo get_class($images); else var_dump(images); If it turns out that it's null, then I'd be curious what the first() is returning to you. You could run the same code on that result. We know it's got to be an object since the error occurred on the size() call and not on images. $first = $pers->lang_image->first(); echo "first is: " . get_class($first); Please let me know what you find?
Mats Posted January 24, 2014 Author Posted January 24, 2014 The first code snippet returns "images is: Pageimage" for the default language. Switching to non-default returns "images is: NULL". The second code snippet returns "first is: RepeaterPage" for default language. Non default language returns "" (empty/nothing).
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