Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Can I style these image(s)!?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #198117
    cscodismith
    Participant

    I know, the title does look a bit weird – I know how to style images but not in this case. In my graphics.php page I have images that are uploaded automatically being ‘written’ or ‘placed’ on the page with a php script as you can see here:

    <div class="photos">
    <?php
    $dirname = "includes/img/uploads/";
    $images = glob($dirname."*.png");
    foreach($images as $image) {
    echo '<img src="'.$image.'" class="img-responsive" alt="Responsive image" /><br />';}
    ?>
    </div>

    I am trying to find a way to make all images that are uploaded placed in a 3 column grid to showcase my graphics that I have done but can’t seem to find a way to correctly style them while in the php tags.

    #198121
    cscodismith
    Participant

    Thanks! I didn’t know I can put html tags inside of my php tags like that – I will try and use this codepen as a reference to style my images.

    #198178
    Anonymous
    Inactive

    I didn’t know I can put html tags inside of my php tags like that

    Yeah… and if you want your text editor to use its pretty colours:

    &lt;?php foreach($images as $image) { ?&gt;
        <li>
            <img />"&gt;
        </li>
    &lt;?php } ?&gt;
    
    #198193
    Ilan Firsov
    Participant

    I prefer to use the alternate syntax and comment the closing tags for things like this:

    <code class="php"><?php foreach($images as $image): ?>
        
  • <?php endif; //foreach($images as $image) ?>

    Maybe sometime in the future you will open the code for this page, and find a lone &lt;?php } ?&gt; and facepalm yourself: “What the heck did I do here and where this bracket belongs to?”

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.