WordPress.org

Ready to get started?Download WordPress

Forums

PHP code to show all images in a folder.. (5 posts)

  1. mwgmediaworks
    Member
    Posted 8 months ago #

    I'm trying to create PHP code to show all images in a specific folder. The code appears to work, but the only thing showing is a small blue box with a question mark in it. Does anyone have a suggestion for the correct coding or a fix for this issue.

  2. Andrew
    Forum Moderator
    Posted 8 months ago #

    You really should post the code with the issue.

  3. mwgmediaworks
    Member
    Posted 8 months ago #

    here is the code I am starting with:

    <?php
    $folder = 'wp-content/gallery/beauty/';
    $filetype = '*.*';
    $files = glob($folder.$filetype);
    echo '<table>';
    for ($i=0; $i<count($files); $i++) {
    echo '<tr><td>';
    echo '<img src="'.$files[$i].'" />';
    echo '</td></tr>';
    }
    echo '</table>';
    ?>

    This is a link to the test page, I am working on:

    http://www.lisagleeson.com/galleries/test/

  4. Andrew
    Forum Moderator
    Posted 8 months ago #

    Instead of this:

    echo '<img src="'.$files[$i].'" />';

    Do this:

    echo '<img src="/'.$files[$i].'" />';
  5. mwgmediaworks
    Member
    Posted 8 months ago #

    Thanks Andrew.... works perfectly now...

Reply

You must log in to post.

About this Topic

Tags

No tags yet.