0

This question is very similar to my other question. I have a website missing millions of Alt Text in body content(not image field). My solution is to set the default Alt Text as the file name without extension. Is it even possible, if so, how?

-- -- added additional info on Oct 2nd 12:40pm for tenken : below is a screenshot of setting

PS: there is no replace setting on Setting section

enter image description here

Here is the screenshot on setting section enter image description here

2 Answers 2

2

Try using the Search and Replace Scanner module to search through the text of your body field. You could use a regular expression to search for image tags without alt attributes.

Some excerpts from the module page:

Features

  • Can search and replace text in CCK text fields, in addition to standard node title and body fields
  • Plain text search and replace regular expression search and replace
  • Case sensitive search option

This module is designed to work on MySQL and dedicated servers, be sure to review the module page and accompanying documentation.

5
  • I have not tried this yet, but will let you know once I did a sample.
    – CocoSkin
    Commented Oct 1, 2014 at 21:03
  • This module does search and replace content or fields. For the Replacement, it does not has any option. I want to replace <img alt="" based on image file name without extension. Something like <img alt="image243" scr="/site/default/files/image243.jpg", <img alt="image412" scr="/site/default/files/image412.jpg"..... not <img alt="samename" scr="/site/default/files/image243.jpg", alt="samename" scr="/site/default/files/image412.jpg" :(
    – CocoSkin
    Commented Oct 2, 2014 at 15:33
  • did you setup what fields you want to scan/replace with after installation? cgit.drupalcode.org/scanner/tree/INSTALL.txt?id=HEAD
    – tenken
    Commented Oct 2, 2014 at 16:15
  • I only see the setting for Scan(search), not the Replace. There only text field allow me to input for replacement. I'm going to update my post with screenshot. Please see above for details
    – CocoSkin
    Commented Oct 2, 2014 at 16:35
  • ya i'm not 100% sure. I would suggest changing the search to regular expression. If needed I would also add a text field to all your nodes temporarily called nid_text and use views bulk operations to set it to the Node ID then include the nid_text in the Search fields try and do a replace using the regular expression and that new text field. Thats the best advice I can think of.
    – tenken
    Commented Oct 2, 2014 at 17:27
1

I'm a big fan of offloading this type of regressive work to the client, meaning I would just write a Javascript function to do the work for me and let the user's browser do the work. With jQuery, it is basically a one-liner. Is there some part of your implementation that would not work with this solution? The upside is that you wouldn't have to worry about tinkering with the database at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.