Batch Apply XMP ALT Tags to EPUB and HTML Images
InDesign CS5.5’s new Object Export Options (found in the Object menu) is a treasure trove of features. One of these is the ability to override InDesign’s default tendency to use an image’s name as its ALT tag, and instead use custom information you’ve entered for the image’s XMP metadata, when you export the document to EPUB or HTML. (Descriptive ALT tags in EPUBs and web sites are important for accessibility, and have other uses. More info on ALT tags here.)
Here’s the default way InDesign links to an image named “06523.jpeg” in an EPUB or HTML file:
<img width="600" height="600" src="images/06523_fmt.jpeg" alt="06523.jpeg"/>
After you use Object Export Options to pull more descriptive text from the image’s XMP data (similar to how Live Captions works), the link might look like this:
<img width="600" height="600" src="images/06523_fmt.jpeg" alt="Chicago's Bike the Drive lets 20,000 bike riders enjoy full access to 20 miles of Lake Shore Drive once a year."/>
The problem is that in this interim CS5.5 release, yes we have an easy and convenient way to add a better ALT tag (thank you Adobe!), but there is no way to use it other than manually applying it to each selected image object, one by one:
- Select the image.
- Choose Object > Object Export Options.
- Select the ALT tab. The default option is “From Structure” (which in practice means “use filename”).
- Choose a different source for the ALT tag from the dropdown menu
- Click the Done button.
- Rinse and repeat for the other images in the file.
Confronted with an EPUB project where I’d need to do this dozens, perhaps hundreds of times, I asked one of our friendly InDesign scripting gurus, Marijan Tompa (@tomaxxi), how difficult it would be to come up with a script that would let the user apply the XMP Description metadata to all the images in the active document at once. Since the XMP Description field is commonly used to hold image captions, I thought that would be one I’d use most often.
Batch-apply ALT tags with ApplyALTfromXMP.jsx script
Another hour later and an updated version of the ApplyALTfromXMP.jsx script arrived in my mailbox. Plus, he added a friendly link back to our site!