Why would you not just specify the jpg file url in the xml feed, and then if there isn't a valid media tag then you'd know it's an image to display?
You can massively reduce the size of your xml if you remove tags you aren't using and remove the parsing lines to handle those empty fields - like a JPG file doesn't need media, streamquality,bitrate,description,streamformat,synopsis,genres,live, etc. You just need the image url and maybe a title if you want it, and add the size dimensions if you want to utilize those.
A big part of how roku works requires understanding how to read a file and manipulate text data within that file.