If is_null
is not working for you that means you are getting some other kind of "empty" value (perhaps an empty string?). You might want to find out why and fix that -- if the data is coming from SQL then it should definitely be null
to signify the absence of an image.
That said, in this case you can simply use the ?:
operator:
echo $smaller_img ?: "http://default image";