本文整理汇总了Python中wagtail.wagtailimages.models.get_image_model方法的典型用法代码示例。如果您正苦于以下问题:Python models.get_image_model方法的具体用法?Python models.get_image_model怎么用?Python models.get_image_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.wagtailimages.models
的用法示例。
在下文中一共展示了models.get_image_model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Image
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def Image(props):
"""
Inspired by:
- https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailimages/rich_text.py
- https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailimages/shortcuts.py
- https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailimages/formats.py
"""
image_model = get_image_model()
alignment = props.get('alignment', 'left')
alt_text = props.get('altText', '')
try:
image = image_model.objects.get(id=props['id'])
except image_model.DoesNotExist:
return DOM.create_element('img', {'alt': alt_text})
image_format = get_image_format(alignment)
rendition = get_rendition_or_not_found(image, image_format.filter_spec)
return DOM.create_element('img', dict(rendition.attrs_dict, **{
'class': image_format.classnames,
'src': rendition.url,
'alt': alt_text,
}))
示例2: test_custom_get_image_model
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def test_custom_get_image_model(self):
"""Test get_image_model with a custom image model"""
self.assertIs(get_image_model(), CustomImage)
示例3: test_standard_get_image_model
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def test_standard_get_image_model(self):
"""Test get_image_model with no WAGTAILIMAGES_IMAGE_MODEL"""
del settings.WAGTAILIMAGES_IMAGE_MODEL
from wagtail.wagtailimages.models import Image
self.assertIs(get_image_model(), Image)
示例4: test_unknown_get_image_model
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def test_unknown_get_image_model(self):
"""Test get_image_model with an unknown model"""
with self.assertRaises(ImproperlyConfigured):
get_image_model()
示例5: test_invalid_get_image_model
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def test_invalid_get_image_model(self):
"""Test get_image_model with an invalid model string"""
with self.assertRaises(ImproperlyConfigured):
get_image_model()
示例6: test_deprecated_get_image_model
# 需要导入模块: from wagtail.wagtailimages import models [as 别名]
# 或者: from wagtail.wagtailimages.models import get_image_model [as 别名]
def test_deprecated_get_image_model(self):
from wagtail.wagtailimages.models import get_image_model
with warnings.catch_warnings(record=True) as ws:
warnings.simplefilter('always')
self.assertIs(Image, get_image_model())
self.assertEqual(len(ws), 1)
self.assertIs(ws[0].category, RemovedInWagtail110Warning)