is now part of CreativePro.com!

Batch Apply XMP ALT Tags to EPUB and HTML Images

7

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:

  1. Select the image.
  2. Choose Object > Object Export Options.
  3. Select the ALT tab. The default option is “From Structure” (which in practice means “use filename”).
  4. Choose a different source for the ALT tag from the dropdown menu
  5. Click the Done button.
  6. 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

To my delight, Marijan emailed me a simple Javascript within the hour, and it worked a treat. Of course I had a few more “gee it would be great if it could also’s” :D including the ability to choose other kinds of XMP metadata, a way to prevent it from overwriting existing custom ALT tags, and a dialog box at the end that showed a count of how many images it worked on.

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!

Since this is a Javascript, it will work on both Mac and Windows platforms. It requires InDesign CS5.5 (the feature it automates doesn’t exist in previous versions).

Click to download ApplyALTfromXMP.zip, then unzip the file and put the ApplyALTfromXMP.jsx file in your scripts folder. (Here are some instructions if you’ve never installed a script before.)

Thank you Marijan! Be sure to check out his site, https://tomaxxi.com/, and if you’re on Twitter, you can follow him at @tomaxxi.

Anne-Marie “Her Geekness” Concepción is the co-founder (with David Blatner) and CEO of Creative Publishing Network, which produces InDesignSecrets, InDesign Magazine, and other resources for creative professionals. Through her cross-media design studio, Seneca Design & Training, Anne-Marie develops ebooks and trains and consults with companies who want to master the tools and workflows of digital publishing. She has authored over 20 courses on lynda.com on these topics and others. Keep up with Anne-Marie by subscribing to her ezine, HerGeekness Gazette, and contact her by email at [email protected] or on Twitter @amarie
  • James Fritz says:

    First off, amazing script. When I first saw this feature in CS5.5, I really liked the idea behind it, but it always seemed kind of clunky since you had to manually add the alt text to everything. Kudos to AM and Marijan for working together on this great script.

    Now to the requests…

    I don’t know if this is possible or not, but here is another idea to improve the script even more.

    Lets say you have a text frame like a caption, but want to keep the exact look of the text: custom font, kerning,etc. To retain this look you can apply custom rasterization to the frame. However, once you do this, you will lose the SEO and accessibility of the content in that frame. I would love to see an option that automatically grabbed the text from any rasterized text frame and added it as custom alt text.

    Is this possible?

    This is probably a request for a different script, but maybe it could be shoehorned into this one.

  • Derek Cross says:

    Hi Anne-Marie
    When is your wonderful new InDesign 5.5 to ePub training title to be published by Lynda.com?
    Derek

  • Hi Derek!

    It should be out in the next few weeks, I just finished recording last week. ;D It needs to go through editing and testing.

  • Frederick Yocum says:

    This is a well crafted little script! My thanks to Marijan and Anne-Marie for suggesting it. It will help as I use CS5.5 in a transition to making more accessible epub and PDF versions of a magazine I design. I just wanted to comment on the difference between the contents of the Description and Alt tag.

    The Description tag is defined by the IPTC as a ? ?caption? . . . used to describe the who, what (and possibly where and when) and why of what is happening in the photograph.? It, essentially, contains information that adds more meaning to what is being viewed.

    The Alt tag, on the other hand, is defined by the W3C as ?fallback content?, information that describes what cannot be viewed.

    Here is a real example:

    This is typical of the information contained in a Description element of a photograph distributed across my organization :

    Trainees can bring their children to Pobitra, where they are cared for by a Pobitra staff worker, Shompa Karmakar, right.

    Pobitra, a MCC Bangladesh job training program for women who wish to leave sex work is based in Mymensignh. In addition to teaching the women skills to produce hand crafts like blankets, clothing and soap, the program provides training in topics which include literacy, numeracy, health and hygiene, legal rights, and English as well as social support, informal counseling and family training/support.

    Here is the Alt element that accompanied the photo when it was displayed on the website:

    Photo of the outside of Probita with the women sitting together by a pool of green water. A women walks around the side carrying a toddler.?

    You can see the photograph on this web page, there is a pdf of the print magazine but it is not tagged, we are heading there.

    In my case, as in most other organizations who embed information in their photographs, having putting the Description information in the Alt tag will usually duplicate what is already in an accompanying caption. This means when a blind person listens to the publication, they will hear the same information twice and not be any more enlightened about what they can?t see. To understand what I mean, listen to a pdf with alt tag information.

    Unfortunately, looking at the IPTC specification there isn?t single element that does what the Alt tag is supposed to do ? describe the scene the photograph shows.

    So, what to do? My strategy, I think, is going to co-opt the Headline element, which I can do thanks to the flexibility of Marijan?s script. I just need to train everyone else in the organization to do the same.

    I stumbled across another resource for dealing with XMP data on Matthew Mariani?s blog. which if you could impose a whole system on your organization, could be really work.

  • Phyllis says:

    Great article! Also, I love Frederick’s comment as I was wondering what to do about how the Description tag is already being used for the Live Captions. Co-opting the Headline field seems like a good idea. It’s amazing that there’s no element for the alt tag (given that there are about a billion fields in the IPTC specs).

    Thanks!
    Phyllis

  • Greg Ledger says:

    Thanks. Hope it gets added to the Preferences panel in the next edition of CS5.5.

  • slate says:

    I read Matthew Marianis blog post about imposing a
    whole system on your organization. Really
    good info/ideas.

  • >