From d5b2ff36b67863eb0fd4b77f89c78103557585ca Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:03:31 -0500 Subject: [PATCH 1/3] feat: do not force external picture link --- .../djangocms_picture/default/picture.html | 22 +++++++++++++++ .../no_link_to_ext_image/picture.html | 28 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 taccsite_cms/templates/djangocms_picture/no_link_to_ext_image/picture.html diff --git a/taccsite_cms/templates/djangocms_picture/default/picture.html b/taccsite_cms/templates/djangocms_picture/default/picture.html index 5e37562fc..15f50ab31 100644 --- a/taccsite_cms/templates/djangocms_picture/default/picture.html +++ b/taccsite_cms/templates/djangocms_picture/default/picture.html @@ -6,14 +6,26 @@ {# /TACC #} {# /TACC #} +{# TACC (allow link to be conditional): #} +{% block picture_link_start %} +{# /TACC #} {% if picture_link %} + {# TACC (allow link to be conditional): #} + {% block picture_link %} + {# /TACC #} +{# TACC (allow link to be conditional): #} +{% endblock %} +{# /TACC #} {% endif %} +{# TACC (allow link to be conditional): #} +{% endblock %} +{# /TACC #} {# start render figure/figcaption #} {# TACC (support children as caption content): #} @@ -49,11 +61,15 @@ {{ picture_size.size.0 }}px " {% endif %} + {# TACC (allow link to be conditional): #} + {% block picture_attributes %} {# TACC (assign attributes to parent): #} {% if not instance.caption_text and not picture_link and not instance.child_plugin_instances %} {{ instance.attributes_str }} {% endif %} {# /TACC #} + {% endblock %} + {# /TACC #} > {# TACC (mimic v3.0.0 to v4.0.0 changes): #} {% endlocalize %} @@ -75,9 +91,15 @@ {% endif %} {# end render figure/figcaption #} +{# TACC (allow link to be conditional): #} +{% block picture_link_end %} +{# /TACC #} {% if picture_link %} {% endif %} +{# TACC (allow link to be conditional): #} +{% endblock %} +{# /TACC #} {% comment %} # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img diff --git a/taccsite_cms/templates/djangocms_picture/no_link_to_ext_image/picture.html b/taccsite_cms/templates/djangocms_picture/no_link_to_ext_image/picture.html new file mode 100644 index 000000000..479af2ce9 --- /dev/null +++ b/taccsite_cms/templates/djangocms_picture/no_link_to_ext_image/picture.html @@ -0,0 +1,28 @@ +{% extends "djangocms_picture/default/picture.html" %} +{# Do not let instance.external_picture trigger picture_link templating #} +{% comment %} +App djangocms_picture assumes external image must be linked to, +but we want to allow external image to be displayed without link. +{% endcomment %} +{# FAQ: picture_link is instance link_url or link_page_id or external_picture #} +{# https://github.com/django-cms/djangocms-picture/blob/3.0.0/djangocms_picture/models.py#L269-L276 #} + +{# So picture with external image is not wrapped in a link #} +{% block picture_link_start %} + {% if instance.link_url or instance.link_page_id %} + {% block picture_link %} + {{ block.super }} + {% endblock %} + {% endif %} +{% endblock %} + +{# So picture attributes can be added to picture with external image #} +{% block picture_attributes %} + {% if not instance.caption_text and not instance.link_url and not instance.link_page_id and not instance.child_plugin_instances %} + {{ instance.attributes_str }} + {% endif %} +{% endblock %} + +{# So picture with external image is not wrapped in a link #} +{% block picture_link_end %} +{% endblock %} From 48a82bf196de381e65ff44fd7bdd216d2c5bf94b Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:37:54 -0500 Subject: [PATCH 2/3] feat: let editor not force external picture link --- taccsite_cms/settings.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 5a71795fb..f0cab4fae 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -585,6 +585,9 @@ def get_subdirs_as_module_names(path): ('right', _('Align right')), ('center', _('Align center')), ] +DJANGOCMS_PICTURE_TEMPLATES = [ + ('no_link_to_ext_image', _('Do not link to external image')), +] # FILE UPLOAD VALUES MUST BE SET! # Set in correlation with the `client_max_body_size 20m;` value in /etc/nginx/proxy.conf. From c260d1e0980c3d1a8779489286b58c256d4df979 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Mon, 7 Apr 2025 15:57:16 -0500 Subject: [PATCH 3/3] deps: @tacc/core-styles v2.41 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ce24bf3b..60f37343a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "minimist": "^1.2.6" }, "devDependencies": { - "@tacc/core-styles": "^2.40.2" + "@tacc/core-styles": "^2.41.0" }, "engines": { "node": ">=16", @@ -1279,9 +1279,9 @@ } }, "node_modules/@tacc/core-styles": { - "version": "2.40.2", - "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.40.2.tgz", - "integrity": "sha512-P0J0TCTzA2rru3Dz8hwBlBwDycKSoeDXO7UmQGPV/oat75abPeeqoUHm2dF/sBxvrka1L00/l2HWbNsl9ettlw==", + "version": "2.41.0", + "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.41.0.tgz", + "integrity": "sha512-oY9hOl60neolmXM9Jpj96cCALocbYsAp10YCbiDh18KaGJb88vI3IkTiX5N2Od4PoJIaIF2Ulo2oH11MaOjvQw==", "dev": true, "license": "MIT", "bin": { @@ -10272,9 +10272,9 @@ } }, "@tacc/core-styles": { - "version": "2.40.2", - "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.40.2.tgz", - "integrity": "sha512-P0J0TCTzA2rru3Dz8hwBlBwDycKSoeDXO7UmQGPV/oat75abPeeqoUHm2dF/sBxvrka1L00/l2HWbNsl9ettlw==", + "version": "2.41.0", + "resolved": "https://registry.npmjs.org/@tacc/core-styles/-/core-styles-2.41.0.tgz", + "integrity": "sha512-oY9hOl60neolmXM9Jpj96cCALocbYsAp10YCbiDh18KaGJb88vI3IkTiX5N2Od4PoJIaIF2Ulo2oH11MaOjvQw==", "dev": true, "requires": {} }, diff --git a/package.json b/package.json index aa145b181..d5e9ef0c0 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,6 @@ }, "homepage": "https://github.com/TACC/Core-CMS", "devDependencies": { - "@tacc/core-styles": "^2.40.2" + "@tacc/core-styles": "^2.41.0" } }