def _format(self):
image = self._dict.get('image')
if image:
self._dict['image'] = self._format_image(image)
if isinstance(image, ImageFieldFile):
image_size = image._get_image_dimensions()
is_large = image_size[0] >= 500 and image_size[1] >= 250
self._dict['card'] = 'summary_large_image' if is_large else 'summary'
super()._format()
# title
title = self._dict.get('title')
if title:
self._dict['title'] = truncatechars(title, 70)
# description
descr = self._dict.get('description')
if descr:
self._dict['description'] = truncatechars(descr, 200)
评论列表
文章目录