B
B
blazer052019-04-29 18:06:23
Django
blazer05, 2019-04-29 18:06:23

How to dynamically display images in a modal window?

Hello.
There is a code in which there is a modal window in which pictures are displayed dynamically. Everything works Pictures are displayed, but only they are all displayed in a modal window. Those. if you click on the picture in one post, the picture from the second one opens, and so on. posts. How to make that when you click on the picture, it opens one for the current post?

{% if rev.image %}
                            <div class="review-block-description">
                                <a href="#" data-toggle="modal" data-target=".dialog1">
                                    <img id="blah" src="{{ rev.image.url }}" width="250" class="img-responsive img-rounded" alt="your image" />
                                </a>
                                <!--  Modal content for Image -->
                                <div class="modal fade dialog1" tabindex="-1">
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
                                                <h4 class="modal-title" id="myLargeModalLabel-1">...</h4>
                                            </div>
                                            <div class="modal-body active">
                                                <img src="{{ rev.image.url }}" class="img-responsive img-rounded center-block" alt="" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                                {% else %}
                                <img src="{% static 'info/reviews/150.png' %}" alt="no foto" title="no image">
                            {% endif %}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-04-29
@blazer05

links have unique class names

B
blazer05, 2019-04-30
@blazer05

Generally did this
and in modal window
everything worked!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question