totoff Posted May 3, 2015 Share Posted May 3, 2015 Hi all, I'm having some trouble to get $image->size() working properly inside a function. I have a function that accepts three arguments: function renderSlides($sites = '', $field = "", $size = "") Later on inside the function I would like to use this argument for cropping my images: $slideimage = $slideimage->size($size); Therefore I set $size in my template: $size = "690,425"; If I check with var_dump(func_get_args()); it confirms I have a string: var_dump(func_get_args(2)); [2]=> string(7) "690,425" Nevertheless if I render the page, I get a PHP warning Warning: Missing argument 2 for Pageimage::size() and the image doesn't get cropped/sized properly. Apologies in advance if this is a dumb question for a PHP pro, but what am I doing wrong here? Thanks! Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 3, 2015 Share Posted May 3, 2015 You're invoking the function with a single argument of the type "string" and the value "690,425", but size() needs two arguments/values, best of the type int. You cannot fake the comma between function arguments. list($w, $h) = explode(",", $size, 2); $w = (int) $w; $h = (int) $h; $slideimage = $slideimage->size($w, $h); 2 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