本文整理汇总了Python中wagtail.wagtailimages.formats.get_image_format函数的典型用法代码示例。如果您正苦于以下问题:Python get_image_format函数的具体用法?Python get_image_format怎么用?Python get_image_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_image_format函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: chooser_select_format
def chooser_select_format(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
if request.POST:
form = ImageInsertionForm(request.POST, initial={'alt_text': image.default_alt_text})
if form.is_valid():
format = get_image_format(form.cleaned_data['format'])
preview_image = image.get_rendition(format.filter_spec)
image_json = json.dumps({
'id': image.id,
'title': image.title,
'format': format.name,
'alt': form.cleaned_data['alt_text'],
'class': format.classnames,
'preview': {
'url': preview_image.url,
'width': preview_image.width,
'height': preview_image.height,
},
'html': format.image_to_editor_html(image, form.cleaned_data['alt_text']),
})
return render_modal_workflow(
request, None, 'wagtailimages/chooser/image_chosen.js',
{'image_json': image_json}
)
else:
form = ImageInsertionForm(initial={'alt_text': image.default_alt_text})
return render_modal_workflow(
request, 'wagtailimages/chooser/select_format.html', 'wagtailimages/chooser/select_format.js',
{'image': image, 'form': form}
)
开发者ID:jalourenco,项目名称:wagtail,代码行数:35,代码来源:chooser.py
示例2: chooser_select_format
def chooser_select_format(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
if request.POST:
form = ImageInsertionForm(request.POST, initial={"alt_text": image.default_alt_text})
if form.is_valid():
format = get_image_format(form.cleaned_data["format"])
preview_image = image.get_rendition(format.filter_spec)
image_json = json.dumps(
{
"id": image.id,
"title": image.title,
"format": format.name,
"alt": form.cleaned_data["alt_text"],
"class": format.classnames,
"preview": {"url": preview_image.url, "width": preview_image.width, "height": preview_image.height},
"html": format.image_to_editor_html(image, form.cleaned_data["alt_text"]),
}
)
return render_modal_workflow(
request, None, "wagtailimages/chooser/image_chosen.js", {"image_json": image_json}
)
else:
form = ImageInsertionForm(initial={"alt_text": image.default_alt_text})
return render_modal_workflow(
request,
"wagtailimages/chooser/select_format.html",
"wagtailimages/chooser/select_format.js",
{"image": image, "form": form},
)
开发者ID:rthauby,项目名称:wagtail,代码行数:34,代码来源:chooser.py
示例3: img_tag
def img_tag(self, extra_attributes=''):
fw_format = get_image_format("fullwidth")
extra_attrs = extra_attributes or ''
if fw_format.filter_spec == self.filter.spec:
return fw_format.image_to_html(
self.image, self.image.title, extra_attrs
)
return super(AffixImageRendition, self).img_tag(extra_attrs)
开发者ID:PARINetwork,项目名称:pari,代码行数:8,代码来源:models.py
示例4: expand_db_attributes
def expand_db_attributes(attrs, for_editor):
"""
Given a dict of attributes from the <embed> tag, return the real HTML
representation.
"""
Image = get_image_model()
try:
image = Image.objects.get(id=attrs['id'])
except Image.DoesNotExist:
return "<img>"
image_format = get_image_format(attrs['format'])
if for_editor:
return image_format.image_to_editor_html(image, attrs['alt'])
else:
return image_format.image_to_html(image, attrs['alt'])
开发者ID:anteatersa,项目名称:Wagtail-Image-Folders,代码行数:17,代码来源:rich_text.py
示例5: get_image_json
def get_image_json(image):
"""
helper function: given an image, return the json to pass back to the
image chooser panel or the editor to set the poster image
"""
format = get_image_format('left')
preview_image = image.get_rendition(format.filter_spec)
return json.dumps({
'id': image.id,
'title': image.title,
'format': format.name,
'alt': image.title,
'class': format.classnames,
'preview': {
'url': preview_image.url,
'width': preview_image.width,
'height': preview_image.height,
},
'html': format.image_to_editor_html(image, image.title),
})
开发者ID:springload,项目名称:wagtailvideoposter,代码行数:20,代码来源:chooser.py
示例6: test_get_image_format
def test_get_image_format(self):
register_image_format(self.format)
result = get_image_format('test name')
self.assertEqual(result, self.format)
开发者ID:Gavryush,项目名称:wagtail,代码行数:4,代码来源:tests.py
示例7: image_halfwidth
def image_halfwidth(sender, instance, **kwargs):
# Create thumbnails for the image
thumbnail_format = get_image_format("halfwidth")
instance.get_rendition(thumbnail_format.filter_spec)
开发者ID:PARINetwork,项目名称:pari,代码行数:4,代码来源:signal_handlers.py
注:本文中的wagtail.wagtailimages.formats.get_image_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论