mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
get_embed never returns None
This commit is contained in:
parent
00d558c9be
commit
0dc4cbcf21
@ -8,20 +8,18 @@ from wagtail.wagtailembeds import embeds
|
|||||||
def embed_to_frontend_html(url):
|
def embed_to_frontend_html(url):
|
||||||
try:
|
try:
|
||||||
embed = embeds.get_embed(url)
|
embed = embeds.get_embed(url)
|
||||||
if embed is not None:
|
|
||||||
# Work out ratio
|
|
||||||
if embed.width and embed.height:
|
|
||||||
ratio = str(embed.height / embed.width * 100) + "%"
|
|
||||||
else:
|
|
||||||
ratio = "0"
|
|
||||||
|
|
||||||
# Render template
|
# Work out ratio
|
||||||
return render_to_string('wagtailembeds/embed_frontend.html', {
|
if embed.width and embed.height:
|
||||||
'embed': embed,
|
ratio = str(embed.height / embed.width * 100) + "%"
|
||||||
'ratio': ratio,
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
return ''
|
ratio = "0"
|
||||||
|
|
||||||
|
# Render template
|
||||||
|
return render_to_string('wagtailembeds/embed_frontend.html', {
|
||||||
|
'embed': embed,
|
||||||
|
'ratio': ratio,
|
||||||
|
})
|
||||||
except embeds.EmbedNotFoundException:
|
except embeds.EmbedNotFoundException:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@ -29,8 +27,6 @@ def embed_to_frontend_html(url):
|
|||||||
def embed_to_editor_html(url):
|
def embed_to_editor_html(url):
|
||||||
try:
|
try:
|
||||||
embed = embeds.get_embed(url)
|
embed = embeds.get_embed(url)
|
||||||
if embed is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Render template
|
# Render template
|
||||||
return render_to_string('wagtailembeds/embed_editor.html', {
|
return render_to_string('wagtailembeds/embed_editor.html', {
|
||||||
|
Loading…
Reference in New Issue
Block a user