syamilmj / Aqua-Resizer

Resize WordPress images on the fly
500 stars 204 forks source link

height and width are mandatory? #94

Closed pluus closed 4 years ago

pluus commented 8 years ago

According to 'How to use',

aq_resize($img_url, $width);

this is a valid code and the update log(v1.1.7) clearly mentions "either $width or $height is required". However, if you take a look at the source code(v1.2.1) of aq_resize function,


// Validate inputs.
if (!$url)
    throw new Aq_Exception('$url parameter is required');
if (!$width)
    throw new Aq_Exception('$width parameter is required');
if (!$height)
    throw new Aq_Exception('$height parameter is required');

this function requires at least three parameters - url, width, and height. Is it supposed to work this way?

menshinobi commented 8 years ago

The ! expression also takes null. If you don't want to pass the height, you should do like this aq_resize($url, $width, null);

That will make the function not throwing exception. But I agree, the doc should be improved.

pluus commented 8 years ago

I see. Thanks, menshinobi !

NautHnim commented 8 years ago

I have the same problem, when I set height to null, it also throw exception. So, i delete "if (!$height)..." and i work normally.

pluus commented 8 years ago

@NautHnim Hmph, I tried it too and it doesn't work :( Clearly, either the source code or the documentation needs to be updated.

mikaelengstrom commented 7 years ago

https://github.com/syamilmj/Aqua-Resizer/pull/65

timcv commented 7 years ago

You can set height = -1, it should work if you want an unspecified height!