Display Alternative Image for Broken Images?

Discussion in 'HTML & Website Design' started by abcdefGARY, Jul 19, 2006.

  1. #1
    Hi. Is there anyway to display an alternative image when there's a broken image?

    So for example, if I forgot to upload an image, it would show something like notavailable.jpg

    thanks

    oh, and is there anyway to disable image links until the page is fully loaded?
     
    abcdefGARY, Jul 19, 2006 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    The object element allows for failthrough.

    A simple example:
    
    <object type="image/jpeg"
            data="some.jpg"
            height="75"
            width="200">
      <object type="image/jpeg" <!-- this is the first alternative -->
              data="another.jpg"
              height="80"
              width="100"></object>
    
      <p>Me, rock climbing.  I'm such a fool.</p> <!-- second alternative -->
    </object>
    Code (markup):
    All modern browsers support the object element. IE is not a modern browser, and its support is crappy. Test. I don't think it will work for IE. The really sad thing is that Lynx, a text only browser, supports object correctly.[1] The trouble is, that's the only mechanism that allows for alternative content. With <img>, you'll have to settle for the alt attribute.

    cheers,

    gary

    [1] It also does inline quotes, the q element, right, while IE fails. Another basic html element not supported by IE. That POS needs to die.
     
    kk5st, Jul 19, 2006 IP
  3. hotcomputers

    hotcomputers Peon

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i will try too.Thanks

    IE is not a modern browser ( LOOOL)
     
    hotcomputers, Jul 19, 2006 IP
  4. DrMalloc

    DrMalloc Peon

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've just set the background property of the images via CSS to the 404 image. When an image loads normally, it'll cover the background. And yes, modern browsers support transparent PNGs too (which disqualifies IE :p)
     
    DrMalloc, Jul 19, 2006 IP
    kk5st likes this.
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    Nice work around. Should work well unless images in general are a problem. Take care about size mis-matches.

    cheers,

    gary
     
    kk5st, Jul 19, 2006 IP