filename to alt text code?

Discussion in 'HTML & Website Design' started by jazzzyman, Mar 10, 2013.

  1. #1
    anybody know how to made code that would automatically pull the filename of a file, remove (-) and insert the name into the alt text?
     
    jazzzyman, Mar 10, 2013 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    That sounds like a job for server side code -- PHP, ASP, Perl, Python, etc, etc... It is not something you can or should be doing 'client-side' in the browser using HTML or Scripting.

    NOT that the filename would be particularly descriptive in most cases -- at least in terms of doing ALT's job... kind of a ha'shakesh approach to alt text. I'd more likely use an array or database server-side to store more meaningful descriptions of the images than would fit into a filename.

    Unless you are REALLY gonna make those filenames meaningful. In my "poor man's" news handler I actually do that for each article's title -- I have the date of the article, an underscore, the title of the article (with spaces in the filename since it's server-side access) followed by the extension ".article.txt".

    PHP's "explode" function then makes it easy. I just str_replace '.article.txt' off the end of it, then use explode to separate the date from the rest of the text. Again, server side code, no real way to do it client side without something like javascript, and one really shouldn't generate an accessibility aid client-side using a technology that a lot of people who NEED alt text will either not even have, or have intentionally blocked from running.
     
    deathshadow, Mar 10, 2013 IP
  3. jazzzyman

    jazzzyman Well-Known Member

    Messages:
    117
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    ok i got ya thanks
     
    jazzzyman, Mar 12, 2013 IP
  4. Noah Wilson

    Noah Wilson Greenhorn

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    it may be possible server side code by using programming language like php, .net .
     
    Noah Wilson, Mar 13, 2013 IP