Fix 'undefined index' error that blocks image rendering

This is similar to pull request #21. Addition is of `isset()` check which handles the undefined index error more robustly. `empty()` simply replaces the `!= ''` check.