Added the legend checking to use the correct HTML tags for an image or an html file.