This is pretty easy to do globally (attach a title to all images that have an non-empty alt tag) but without some other way to tell which images you mean to apply this method to, it becomes a bit scattershot. If you recall the bad old days of IE 3 and 4, when hovering over any image for any length of time would bring up this nasty overlay giving you the options to download it, imagine if every image on your site suddenly had a title attribute, and you couldn’t hover the mouse anywhere without triggering a tooltip.
So here’s two ways to do this. The first relies on you setting an empty alt attribute for any image that doesn’t need the tool-tip; the second relies on you including the letters “left parenthesis”, “lower-case C”, “right parenthesis” in that order in the alt text. (I didn’t put those together in text here, because it would just confuse any Web viewers – that combination of letters is automatically transformed into a Copyright symbol by the Markdown interpreter on the Web archive of this list.)
To begin (for either approach) apply the Protaculous Action to your page, and choose prototype-packed from the Library menu. Click on the top Function Body button, and paste in ONE OF THE FOLLOWING snippets (not both).
$$('img[alt!=""][title=""]').each(function(elm){
elm.writeAttribute('title', elm.readAttribute('alt'));
});
or this
$$('img[alt*="(c)"][title=""]').each(function(elm){
elm.writeAttribute('title', elm.readAttribute('alt'));
});
(Hopefully, that second example doesn’t have a copyright symbol sitting in the middle of it if you’re looking at this on the Web.)
So the first of these will add a title to any image that has a non-empty alt attribute, and the second will only attach to elements that 1. have a non-empty alt, and 2. have an alt that contains the letters ( c ) (together).
Walter
On Dec 16, 2012, at 11:48 AM, seoras wrote:
but the text that would appear in that title attribute is to be found elsewhere on the same page?
Hi Walter,
Not sure what you mean by that line but here is a link: www.pkht.org.uk/projects.php
Line 305 is the alt=
If its a hassle then no big deal to say no to client, it was just an after thought. Personally I would be happy just having image details at the bottom of the article. With more cms sites these days it might be useful.
thanks,
s
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options