From 0dc4cbcf218339fa668b7d50452b797fc7c58e31 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Fri, 5 Jun 2015 14:21:02 +0100 Subject: [PATCH] get_embed never returns None --- wagtail/wagtailembeds/format.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/wagtail/wagtailembeds/format.py b/wagtail/wagtailembeds/format.py index cedb78e1c6..96108f94ef 100644 --- a/wagtail/wagtailembeds/format.py +++ b/wagtail/wagtailembeds/format.py @@ -8,20 +8,18 @@ from wagtail.wagtailembeds import embeds def embed_to_frontend_html(url): try: 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 - return render_to_string('wagtailembeds/embed_frontend.html', { - 'embed': embed, - 'ratio': ratio, - }) + # Work out ratio + if embed.width and embed.height: + ratio = str(embed.height / embed.width * 100) + "%" else: - return '' + ratio = "0" + + # Render template + return render_to_string('wagtailembeds/embed_frontend.html', { + 'embed': embed, + 'ratio': ratio, + }) except embeds.EmbedNotFoundException: return '' @@ -29,8 +27,6 @@ def embed_to_frontend_html(url): def embed_to_editor_html(url): try: embed = embeds.get_embed(url) - if embed is None: - return # Render template return render_to_string('wagtailembeds/embed_editor.html', {