django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.76k stars 577 forks source link

'File' object has no attribute 'width' #1394

Closed wagnerfelix closed 1 year ago

wagnerfelix commented 1 year ago

Hi, we use our own Image model and we recently updated our code to work with 3.0.2 from 2.2.4. After upgrading we noticed that we could not access the details of files. The cause is fix: Prevent server errors in image detail view if images do not exist. Specifically templates/admin/filer/tools/detail_info.html, in line 6 the templatetag {% file_icon original detail=True %} causes an issue. The "offending" code is in filer/templatetags/filer_admin_tags.py:

    ...   
    if detail:
        context['download_url'] = file.url
        if file.width:
            width, height = 210, ceil(210 / file.width * file.height)
            context['sidebar_image_ratio'] = file.width / 210
    ...

'File' object has no attribute 'width'. After downgrading to 3.0.1 the issue goes away. Regards

vinitkumar commented 1 year ago

@wagnerfelix Well spotted. Indeed, this was introduced recently. I will make a patch to fix this.