php loop of images with bootstrap

Asked

Viewed 47 times

0

I have this code that brings some Instagram images, I want to stay 3 photos by row (line);

Then if there are more than 3, create another Row.

my code:

<div class="row">
                      <?php foreach ($insta_user->edge_owner_to_timeline_media->edges as $value): ?>
                      <div class="col-md-4">
                      <?php
                      $return_user_insta = (object) [
                        'id'          => $value->node->id,
                        'display_url' => $value->node->display_url
                      ];
                      echo '<img src="' . $return_user_insta->display_url . '" class="img-fluid"';
                      ?>
                      </div>
                      <?php endforeach ?>
                    </div>

It’s just that when I do that, it just sucks, and it’s like this:

inserir a descrição da imagem aqui

what I’m doing wrong ?

1 answer

1


The tag <img> of your code is not closed. Add a > at the end that will stay like this:

echo '<img src="' . $return_user_insta->display_url . '" class="img-fluid">';
  • Jeez.. what nonsense, lack of attention... but thanks as soon as I give the time I mark as solved ok?

  • 1

    Lack of attention happens a lot. Simple things like this can cause a problem that you can barely solve...

  • Another thing, taking advantage of the post... Bootstrap has to configure to leave some active images only on mobile? I’m new with bootstrap

  • 1

    Boootstrap is to make content responsive in multiple resolutions... If you want to make the image appear only on your phone you should create a class and apply the @media (CSS) property to it and make the class style apply only to a certain size at screen resolution

Browser other questions tagged

You are not signed in. Login or sign up in order to post.