properly set the alt attribute value to the defined text if it exists, otherwise set to the title.