opengraph.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:tumanov_castleoaks 作者: Roamdev 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号