Automatically adding alt tags for images
So since being W3C compliant is supposed to help with search optimization I've always wanted to be able to automatically add alt tags to images that don't have them. Since alot of the content on our websites is entered via a cms, we don't always have complete control over this.
I've seen regular expressions that are supposed to detect img tags without alt tags in them, but couldn't get this to work the way I wanted it to.
I think I've found a good solution to this. I'm just using regular expressions to find all image tags, then going through a list of them, finding ones without alt tags, and then trying to process the src tag to come up with a guess as to what a good choice for the alt tag would be.
Here it is, remember you've got to have (using System.Text.RegularExpressions;) at the top of the cs file
fixalt.txt
I've seen regular expressions that are supposed to detect img tags without alt tags in them, but couldn't get this to work the way I wanted it to.
I think I've found a good solution to this. I'm just using regular expressions to find all image tags, then going through a list of them, finding ones without alt tags, and then trying to process the src tag to come up with a guess as to what a good choice for the alt tag would be.
Here it is, remember you've got to have (using System.Text.RegularExpressions;) at the top of the cs file
fixalt.txt
Labels: .net, alt, alt tag, automatic, c#, compliant, html, images, img, regular expression, w3c
