|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Adding ALT tags to an existing site
Hi,
I have a website made up of 400+ pages all of which have images without alt tags. 90% of the images are layout graphics and only need the alt"" added. Is there any software/plugin that will automate this for me so I don't need to edit each page of my website manually. Thank You. |
|
#2
|
|||
|
|||
|
Sorry to say this, but I think that you will need to manually just add the alt.
|
|
#3
|
|||
|
|||
|
No, no you won't. Pick a platform of your choice, such as PHP. Make use of PHP's File functions, then mix some regex in and you will have a script that you can use to automate the addition of your alt variables. Have a look into it and post back if you get stuck.
|
|
#4
|
||||
|
||||
|
You can do this pretty easily using DW's Find and Replace.
Just search: Entire Current Local Site Find: <img[space] Replace with: <img alt=""[space] And that will find all img tags on the site, and replace with the same img tag, and add the alt tag.
__________________
|
|
#5
|
|||
|
|||
|
That would be a horrible idea for 400+ pages. Take so long.
|
|
#6
|
||||
|
||||
|
Quote:
Actually it wouldn't take that long at all. The engine it uses is pretty good. I've done Find and Replace on sites with 1500+ pages and it worked great! |
|
#7
|
|||
|
|||
|
I think that PHP-newbs idea of PHP would work great. His pages would have to have the img tag set up ALL like
<img alt="" src="whatev.jpg"> Otherwise, your example won't work I think. |
|
#8
|
||||
|
||||
|
Quote:
But why write extra code and spend time testing/debugging when a program already contains the task needed. Agreed, not all images have the same dimensions, or filenames, but all image tags do have something in common. They all do start with <img So if the user was to do a search for <img and did "Find All" he would get a # result of how many results were found matching the <img criteria. Remember this #. Now if were to "Find" <img and "Relace" with <img alt="" we aren't extracting anything, we are searching for a common tag used by all image tags, and we are adding to that tag along with a space so as not to mess up the attributes assignment. After you get finished doing the Global F&R, check the # of results it replace and see if it matched the original # of results found, described in the 2 paragraphs above. If you really want to make sure, you can go into the Advanced Find and Replace and do even more matching, with certain criteria. DW's F&R feature is quite extensive, and it was made for task exactly as described by the OP. Try out! Just copy some source code from a large site, and try a simple find and replace. Its def a time saver once you get more comfortable using the feature. HTH's explain it a little better. **Edit: Want to add after I re-read your post. if a user has an image tag like: <img src="whatev.jpg"> I am only going to match the first 5 characters <img[space] Anything after that I am not touching and it retains it's orginal content. So if I did a global F&R on the above tag, after the F&R is done, it would look like: <img alt="" src="whatev.jpg"> Because I replaced: <img[space] With: <img alt=""[space] Reason why I include the space is so the attributes don't butt up against each other. Last edited by zer0efx : May 1st, 2008 at 11:31 AM. Reason: add more detail |
|
#9
|
|||
|
|||
|
I was just thinking general purpose with regards to a script. A grep and replace would be faster for a one-time issue.
|
|
#10
|
||||
|
||||
|
I might use both a text editor with a search and replace in multiple files feature and PHP to do this, because copying that many files via FTP would take a while.
The alt attribute doesn't have to be first either, but it is simpler to do it that way.
__________________
Spreading knowledge, one newbie at a time. Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions IE7: the generation 7 browser new in a world of generation 8 browsers. Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around. |
|
#11
|
||||
|
||||
|
You could use Sed, if you got access to it, it is perfect for this kind of work.
http://www.grymoire.com/Unix/Sed.html http://en.wikipedia.org/wiki/Sed |
|
#12
|
|||
|
|||
|
Thanks for all the replies.
I managed to do it with dreamweaver search and replace. I did come across a dreamweaver plugin that might be useful for others with a similar problem - http://divahtml.com/products/divaFr...eaver_tools.php Thanks. |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Adding ALT tags to an existing site |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|