• vijayj

    (@vijayj)


    I have a folder in my wp-uploads named my_images.
    How can I get all the images including gifs with a function.I also need the name of image file.

    <?php
    $files = glob("images/*.*");
    
    for ($i=0; $i<count($files); $i++) {
        $image = $files[$i];
        print $image ."<br />";
        echo '<img src="'.$image .'" alt="Random image" />'."<br /><br />";
    }
    
    ?>

    I tried this.But all the time I am getting $files count as 0.

    • This topic was modified 5 years ago by Jan Dembowski. Reason: Formatting
Viewing 1 replies (of 1 total)
  • I think you may need to change $files = glob("images/*.*"); to point to the WP Content Directory. Try this:

    $files = glob(WP_CONTENT_DIR . "images/*.*");

Viewing 1 replies (of 1 total)
  • The topic ‘Get Image details from wp-uploads sub-folder.’ is closed to new replies.