Skip navigation
WisDOT-PubEditor
Currently Being Moderated

Copy alt text to title [Branched from: WildCard Find & Replace Question]

Aug 11, 2012 7:08 AM

Fabulous, so now I am able to add the code (alt=" ") to any image that does not already have one. Now is there a way to do a similar task AND have the replace function fill in the text based on existing info.?

My situation is I have images with alt text AND now have to add title info. to the image (title=" ") that is a duplicate of the alt text.

SO, is there a way to tell the system to find all alt text tags and replace them with alt text and title tag, where the title tag is a duplicate of the alt info.?

 

     FIND alt="*.*"

     REPLACE with alt="*.*" title="*.*"

 

I tried *.* and that does not work.

Branched from an earlier discussion.
 
Replies
  • Currently Being Moderated
    Aug 11, 2012 7:21 AM   in reply to WisDOT-PubEditor

    Please don't add new questions to a year-old thread. I have branched this to a new thread.

     

    First of all, although it's possible to do what you want, it's not a good idea. The purpose of alt text is to provide a description of an image for the benefit of text-only browsers and assistive technology for the blind. The purpose of the title attribute is to add extra information.

     

    If both the alt text and the title attribute contain the same information, that information is read aloud twice by screen readers for the blind, driving them stir crazy.

     

    Having said that, if you're determined to go ahead, this is how you do it.

     

    1. Back up the file(s) you want to edit.
    2. In the Find and Replace dialog box, select Search Source Code
    3. Put the following in the Find field:  alt="([^"]+)"
    4. Put the following in the Replace field: alt="$1" title="$1"
    5. Select the "Use regular expression" checkbox.
    6. Click Replace All.

     

    The values for the Find and Replace fields must be copied exactly as they are.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 13, 2012 7:34 AM   in reply to WisDOT-PubEditor

    WisDOT-PubEditor wrote:

     

    I tried the method you suggested and below is the original code AND then the resulting code. The results only added the info. entered in the replace box verbatim and didn’t copy the alt text and place it in the title tag. It even overwrote my existing alt text.:

    If that's the case, you have misunderstood my instructions. Below is a screenshot of your image tags and the correct settings in the Find and Replace dialog box. As you can see (you'll need to click the image to enlarge it), the alt text has been correctly copied into the first image tag. The second alt text is selected ready for the replace operation.

     

    regex.jpg

    The alt text isn't meant to be displayed as a tooltip. Internet Explorer is the only browser that has ever used alt text in that way. As you correctly say, the value of the title attribute is displayed, not only by IE, but by all browsers. But the content of the two attributes should be different. I'm not aware of any way around your situation.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 13, 2012 3:00 PM   in reply to WisDOT-PubEditor

    WisDOT-PubEditor wrote:

     

    I c and now know what the issue is. Your instructions are for Dreamweaver

    Well, that's not surprising since the question was asked in the Dreamweaver forum.

     

    Alas I am only able to use MS Expressions Web version 3 at my govt. work. Do you know how one would do it in MS EW?

    Alas, indeed. I happen to have both Expression Web 3 and EW4, and have tested Find and Replace using regular expressions. For reasons known only to Microsoft, you can use regular expressions to find text, but you can't make use of capturing parentheses for replace operations.

     

    Unfortunately, Expression Web is a pale imitation of Dreamweaver, albeit with a more modern interface. I don't know of any way of doing what you want with that program. Sorry.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)