how to check image on if statement?

Discussion in 'HTML & Website Design' started by mark103, Mar 7, 2013.

  1. #1
    Hi guys,

    Can you please help me, I want to find out how I can check on if statement using with html or javascript to see if the image on the webpage does exist then replace the image.

    Does anyone know how i can do this?

    thanks in advance
     
    mark103, Mar 7, 2013 IP
  2. shelby1324

    shelby1324 Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #2
    firebug plug in for Firefox browser. use it to inspect any element
     
    shelby1324, Mar 7, 2013 IP
  3. mark103

    mark103 Active Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    that is making no sense, i want to know how I can create a filename for the image on the webpage and I also want to out how I can check on the if statement to see if the image on the webpage is exist.

    Like this:
    
    $image1 = <div id="image1" style="position:absolute; overflow:hidden; left:415px; top:157px; width:114px; height:81px; z-index:0"><img src="/images/tvguide_blue.jpg" alt="" title="" border=0 width=114 height=81></div>
    
    Code (markup):

    On my webpage, it display as "$image =". Do you know how i can create a function for a filename so I can write something like this:

    if ($image = exist) { 
      // do something
    } 
    
    Code (markup):
    Do you have any idea?

    thanks in advance
     
    mark103, Mar 7, 2013 IP
  4. TechGuy1

    TechGuy1 Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    68
    #4
    What language? Are you using PHP?
     
    TechGuy1, Mar 7, 2013 IP
  5. mark103

    mark103 Active Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #5
    I am using html.
     
    mark103, Mar 7, 2013 IP
  6. shelby1324

    shelby1324 Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    that doesn't look like html.
     
    shelby1324, Mar 7, 2013 IP
  7. shelby1324

    shelby1324 Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #7
    give a link to your webpage.
     
    shelby1324, Mar 7, 2013 IP
  8. TheLimeDesign

    TheLimeDesign Well-Known Member

    Messages:
    504
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #8
    I usually use PHP to do this..You need to explicitly manipulate the code that you are altering..

    function manipulate_image($the_output) {
    $breakdown = '/<a(.*?)href="(.*?).(bmp|gif|jpeg|jpg|png)"(.*?)>/i';
    $manipulate = image_ID(); /* In this case, I'm injecting an ID into my statement from a function defined elsewhere */
    $newstatement = '<a$1href="$2.$3" id=\'.$gettheID.\'$4>';
    $the_output = preg_replace ($breakdown,$manipulate,$the_output);
    return $the_output;
    }

    This will inject an ID into my images. You just wanted the query images string, this one has it. Additionally, this teaches you how to manipulate the statement.

    Hope it helped :)
     
    TheLimeDesign, Mar 7, 2013 IP
  9. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #9
    Do you want to see whether the image file exists on the server, or whether the image is showing in the user's browser? (If in the browser, there's no filename associated with the "image" - the image file is sent to the user's browser, and it's up to the browser to show it. Assume that it's showing. You can't check to find out if it is.)
     
    Rukbat, Mar 8, 2013 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #10
    HTML is not a programming language (wow, me saying that!) in that it doesn't HAVE "if" statements, it doesn't HAVE variables... The dollar sign on a variable makes it LOOK like you are using PHP hence others reaction, but the lack of quotes makes no sense whatsoever.

    In general all your posts are gibberish -- I don't think you are fully grasping the technologies you are trying to use as your terminology is all wrong, which is why all the responses are incomprehensible as well.

    I can't even figure out what you are asking -- as Rukbat was saying are you asking for if it exists on the server (PHP or some other server-side language), or that it's loaded client side? (Javascript's onload method)... as to 'replacing' it, that shouldn't be done client side (HTML) at all... You're question just doesn't make any sense.
     
    deathshadow, Mar 8, 2013 IP