當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。