#/usr/local/bin/perl -w
use strict;
############################################################
# #
# #
# #
# NOAH SUSSMAN #
# #
# insert_alt #
# #
# Created 5/11/01 at 01:38 PM #
# #
# Insert ALT element into IMG tags that lack it. The alt #
# text inserted is identical to the contents of the <TITLE>#
# tag -- or not. #
# #
# #
############################################################
=item THIS NEEDS TO BE ADJUSTED SO IT WORKS WITH JSP
(02:35:50) VERSUSearth: I'll have to adjust my insert_alt script to take JSP into account next time
(02:36:35) mitiege: yep- I'm guessing you are looking for the first closing sign and inserting before that..
(02:36:47) mitiege: a simple fix would be to put the alt first in the img tag...
(02:37:06) VERSUSearth: yeah that's probably a good idea
=cut
$^I=".bk";
#undef $/; # read in whole file, not just one line
my $text = "" ; #Insert blank alt attribute
while (<>) {
#m{<title>(.*?)</title>}ix;
#my $text = $1; #Use the document title as the ALT text
unless (m{<img.*?alt=.*?>}ix){
s{(<img)(.*?)>}{$1$2 alt="$text">}gsix;
}
print "$_";
}
insert ALT attribute into IMG tags that don’t already have ALT attributes
Category: Uncategorized |
Tags: 2001, accessibility, alt, beginnersperlorg, filter, html, images, optimization, standards
Leave a Reply
You must be logged in to post a comment.