Loading ...
Sorry, an error occurred while loading the content.
 

Re: [phpXperts] "file_exists" Problem in wordpress

Expand Messages
  • Tareq Hasan
    The image path you are generating is a url to the image, not the file path. So you can t check the existence of a url with file_exists() function. Instead of
    Message 1 of 3 , Apr 19, 2012
      The image path you are generating is a url to the image, not the file path. So you can't check the existence of a url with file_exists() function.

      Instead of using get_bloginfo('template_directory'), use TEMPLATEPATH constant
      --------------------------------------------
      Best regards
      Tareq Hasan
      Blog | Twitter

    • Bijon
      Finaly its done, thanks to all. and my coding...
      Message 2 of 3 , Apr 21, 2012
        Finaly its done, thanks to all. and my coding...

        <?php
        $pid=get_the_ID();
        $imagepaths=get_bloginfo('template_directory')."/singelpage/".$pid.".jpg";
        $imagepath=TEMPLATEPATH."/singelpage/".get_the_ID().".jpg";
        if(file_exists($imagepath))
        { ?>
        <div id="singelpagehimage" title="<?=$post->ID?>" >
        <img src="<?php echo $imagepaths; ?>" alt="<?php the_title();?>"/>
        </div>
        <?php } ?>
      Your message has been successfully submitted and would be delivered to recipients shortly.
      »
      «