当前位置: 首页>>代码示例>>Python>>正文


Python models.get_image_model方法代码示例

本文整理汇总了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,
    })) 
开发者ID:springload,项目名称:wagtaildraftail,代码行数:26,代码来源:decorators.py

示例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) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:5,代码来源:tests.py

示例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) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:7,代码来源:tests.py

示例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() 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:6,代码来源:tests.py

示例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() 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:6,代码来源:tests.py

示例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) 
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:10,代码来源:tests.py


注:本文中的wagtail.wagtailimages.models.get_image_model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。