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" } } diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 6eba7dde5..9442a82ac 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -584,6 +584,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. 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 %}