melinath / django-daguerre

On-the-fly image manipulation for Django.
http://django-daguerre.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
85 stars 15 forks source link

Can't access adjusted image's width and height #105

Closed pembeci closed 4 years ago

pembeci commented 7 years ago

I am trying this example from the docs with Django 1.10 and Pythton 3.6:

{% load daguerre %}
{% adjust my_model.image 'fit' width=128 as image %}
<img src="{{ image }}" width="{{ image.width }}" height="{{ image.height }}" />

The url and adjustment works just fine but image.width and image.height are undefined (or an empty string). I installed the latest version (2.2.2) from pip. When I debug the variable I got this:

{'adjust_uses_areas': False, 'adjusted': {}, 'adjustment_sep': '>', 'adjustments': [<daguerre.adjustments.Fit object at 0x7f59ad7fdc88>], 'calc_uses_areas': False, 'generate': False, 'get_query_kwargs': 'routine', 'iterable': ['logos/bird_logo.png'], 'lookup_func': 'routine', 'param_sep': '|', 'query_map': {'requested': 'r', 'security': 's'}, 'remaining': {}, 'requested': 'fit|166|66', 'to_querydict': 'routine'}

Am I doing something wrong or can this be a regression? Thanks.

melinath commented 4 years ago

yes, this is a regression. We made upgrades in the past to better handle iterables of images and seem to have lost the ability to correctly handle single images.

melinath commented 4 years ago

hm, this is also specific to the {% adjust %} template tag - people using iterables are supposed to use {% adjust_bulk %}