From aefb0f9506fc1eb3615b4a189996e292e9e37464 Mon Sep 17 00:00:00 2001 From: Kalob Taulien Date: Thu, 9 Jan 2020 18:22:05 -0700 Subject: [PATCH] Responsive emebed setting --- CHANGELOG.txt | 1 + docs/releases/2.8.rst | 3 ++- docs/topics/writing_templates.rst | 1 + wagtail/embeds/models.py | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 428ffc5b5..4d6495ffb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -23,6 +23,7 @@ Changelog * Add partial experimental support for nested InlinePanels (Matt Westcott, Sam Costigan, Andy Chosak, Scott Cranfill) * Added cache control headers when serving documents (Johannes Vogel) * Use `sensitive_post_parameters` on password reset form (Dan Braghis) + * Add ``WAGTAIL_ENABLE_RESPONSIVE_EMBED`` setting to remove automatic addition of ``responsive-object`` around embeds (Kalob Taulien) * Fix: Rename documents listing column 'uploaded' to 'created' (LB (Ben Johnston)) * Fix: Unbundle the l18n library as it was bundled to avoid installation errors which have been resolved (Matt Westcott) * Fix: Prevent error when comparing pages that reference a model with a custom primary key (Fidel Ramos) diff --git a/docs/releases/2.8.rst b/docs/releases/2.8.rst index 90b4c868f..9e4156895 100644 --- a/docs/releases/2.8.rst +++ b/docs/releases/2.8.rst @@ -43,6 +43,7 @@ Other features * Add partial experimental support for nested InlinePanels (Matt Westcott, Sam Costigan, Andy Chosak, Scott Cranfill) * Added cache control headers when serving documents (Johannes Vogel) * Use ``sensitive_post_parameters`` on password reset form (Dan Braghis) + * Add ``WAGTAIL_ENABLE_RESPONSIVE_EMBED`` setting to remove automatic addition of ``responsive-object`` around embeds (Kalob Taulien) Bug fixes @@ -124,7 +125,7 @@ New code: The ``get_document_model`` function should now be imported from ``wagtail.documents`` rather than ``wagtail.documents.models``. See :ref:`custom_document_model`. -Removed ``Page`` and ``Site`` models from Django admin +Removed ``Page`` and ``Site`` models from Django admin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ``Page`` and ``Site`` models are no longer editable through the Django admin backend. If required these models can be re-registered within your own project using `Django's ModelAdmin `_: diff --git a/docs/topics/writing_templates.rst b/docs/topics/writing_templates.rst index 1170c46a6..7b911bd61 100644 --- a/docs/topics/writing_templates.rst +++ b/docs/topics/writing_templates.rst @@ -145,6 +145,7 @@ Wagtail includes embeds and images at their full width, which may overflow the b height: 100%; } +It's possible to disable responsive embeds entirely by setting ``WAGTAIL_ENABLE_RESPONSIVE_EMBED = False`` in your settings. Normally, Wagtail wraps your embed links in a ``
`` element. If you decide to disable responsive embeds the ``
`` element around your embed will not be given a CSS class of ``responsive-object`` and there won't be an inline style in the same parent ``
`` element. This means the responsiveness of your embed is entirely up to you. Internal links (tag) ~~~~~~~~~~~~~~~~~~~~ diff --git a/wagtail/embeds/models.py b/wagtail/embeds/models.py index 9444e794c..e1a061bf8 100644 --- a/wagtail/embeds/models.py +++ b/wagtail/embeds/models.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -50,6 +51,8 @@ class Embed(models.Model): @property def is_responsive(self): + if not getattr(settings, 'WAGTAIL_ENABLE_RESPONSIVE_EMBED', True): + return False return self.ratio is not None def __str__(self):