Search code examples
pythondjangoimagedjango-cmseasy-thumbnails

Image uploaded increases size in Django-CMS


I've got a django-cms plugin with a image field and I've noticed that the size of the images I upload using this plugins is bigger than the originals one. This can't happen, do you have any idea what could be causing this? Could it be some kind of configuration?

The definition of the field in the models.py:

image = models.ImageField(db_column='IMAGE', verbose_name=_(u'Image (1280x600)'), upload_to='Destaques')

This is a snippet of the template where I render the image: {% load cms_tags staticfiles i18n %} {% load thumbnail %}

{% thumbnail  instance.imagem '1660' as im %}
<div class="item" id="item_{{ instance.id }}" style="background: url('{{ im.url }}') no-repeat center / cover;">

Could it be because of the thumbnail generation?

Thank you :)

{% endthumbnail %}

Solution

  • Assuming you are using the easy-thumbnails plugin, in your thumbnail tag:

    {% thumbnail  instance.imagem '1660' as im %}
    

    the '1600' is specifying the size of the generated thumbnail. The format for the size is given in the docs as [width]x[height] and since you only have a single number it is interpreted as as width of 1660px. If the uploaded image was 1280x600 it would generated a thumbnail that is 1660x778.