문제

Suppose, I have 20 images of size 1600 X 900 in a page. How do I load the images in the size that I specify on a template? In the css I can do it. But I want to change the actual size of the image, so that when clicked on the particular image, it will load the original image with its original size. Is there any way that I can do it? I tried using easy_thumbnails and it was great, until it gave me problems when I deployed it using the apache server. Any help will be deeply appreciated. Thank you!

EDIT:

.html:

 {% for Status in status %}
    <p class="user">{{ Status.creator.get_full_name }}</p>
    {% if Status.image %}
        <div class="image_image">
            <center>
                <img src="{{ MEDIA_URL }}{{Status.image}}" width=300px />
            </center>
        </div>
        <p class="status_image">{{Status}}</p>
        <span class="clear"></span>
        <hr>
    {% else %}
        <p class="status_status">{{Status}}</p>
        <span class="clear_right"></span>
        <hr>
    {% endif %}
{% endfor %}
도움이 되었습니까?

해결책

Try to use sorl thumbnail, it even supports Amazon S3 Server.

pip install sorl-thumbnail

To Installed apps: 'sorl.thumbnail',

add {% load thumbnail %} to your template.

{% thumbnail firma.firma_logo "130x110" format="PNG" as im %}
        <div class="logo" style="background-image:url('{{ im.url }}')"></div>
{% endthumbnail %}

The make image format PNG is important, it converts into JPEG by the default. And if the user uploads file in transparent format, it sucks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top