Accessing image dimensions on an ImageField in a Django template?

后端 未结 2 1762
被撕碎了的回忆
被撕碎了的回忆 2021-02-07 01:08

I have ImageField in my model and I\'m able to display the image in a template. However, how do I retrieve the image\'s height and width?

2条回答
  •  轮回少年
    2021-02-07 01:32

    See the documentation for ImageField.

    In addition to the special attributes that are available for FileField, an ImageField also has height and width attributes.

    So just do the following:

    
    

提交回复
热议问题