ORDER BY
photo IS NULL,
photo
checks two things:
1st: photo IS NULL evaluates to 0 if it's not NULL and 1 if it's 0 => NULL values go after non-NULL values
example:
abc
NULL
def
NULL
b
x
NULL
h
will be sorted to:
abc
def
b
x
h
NULL
NULL
NULL
and in 2nd step all the non-NULL values will be compared and sorted:
abc
b
def
h
x
NULL
NULL
NULL
(that's not how it really works but you can use this for getting an idea of how it works)