Marco Ro Posted July 12, 2018 Share Posted July 12, 2018 Hi, I have a problem with resize images in a multi languages website. If I use the size() or width() the image give me back a null result. This one is an example of my code: $image_big = $post->getInputField('image_card')->getImage(); // this one is form ImagenPicker $image_small = $image_big->width(600); echo '<img src="' . $image_small->url . '" alt="business furnitur playwood">'; The ImagenPicker module work well, I don't think the problem is about this. This code in the first language work well and the image are resized. But when I change language give me this error: Error Call to a member function width() on null Some one the help me to understand why this happen? Thank you. Link to comment Share on other sites More sharing options...
theo Posted July 12, 2018 Share Posted July 12, 2018 If it says that it called width() on null, then ImagePicker's getImage() returned null. You should always check the return value for null. I do not know why it can't find the image in your case for other languages. I can't reproduce this problem. I suggested here that you could try to see what is going on in getAImage($imgpath) using var_dump or Tracy Debugger. Did you do this? 2 Link to comment Share on other sites More sharing options...
Marco Ro Posted July 12, 2018 Author Share Posted July 12, 2018 3 hours ago, theo said: If it says that it called width() on null, then ImagePicker's getImage() returned null. Yes it's is true, but only in one language, me to I don't know why in the default language work well. 4 hours ago, theo said: getAImage($imgpath) using var_dump or Tracy Debugger. Thank you @theo for the advice and for the help. Unfortunately I don't think I can do what you say. I tried but I'm sure it's not this that I have to do. $image_big = $post->getInputField('image_card')->getImage(); // this one is form ImagenPicker $image_small = $image_big->width(600); var_dump($image_small); object(ProcessWire\Pageimage)#609 (2) { ["changes"]=> array(1) { [0]=> string(8) "basename" } ["data"]=> array(6) { ["basename"]=> string(31) "karya_220x118x74_cara.600x0.jpg" ["description"]=> string(0) "" ["tags"]=> string(0) "" ["formatted"]=> bool(false) ["modified"]=> int(1523373826) ["created"]=> int(1523373826) } } If I do this in the second language give me: Call to a member function width() on null. I'm not sure this is the var_dump that I have to do. Link to comment Share on other sites More sharing options...
theo Posted July 12, 2018 Share Posted July 12, 2018 This is too late to "var_dump". As I said, try var_dump or debugger in InputfieldImagePicker.module in private function getAImage($imgpath). The code in there is supposed to find an image object by its path name. Try to find out why it returns null. I have no idea what it might have to do with the selected language. Afaik images are the same for different languages. P.S. are you sure you have the updated version? https://github.com/theo222/ImagePickerField/blob/master/InputfieldImagePicker.module Link to comment Share on other sites More sharing options...
Marco Ro Posted July 13, 2018 Author Share Posted July 13, 2018 Thank you @theo, I'm sorry but I don't know how to make the var_dump or debugger in module. so, I will study how do it and I will try to make the check. 16 hours ago, theo said: P.S. are you sure you have the updated version? yes, I have upload the module to the last version. Thank you again. 1 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