Skip to content

Commit

Permalink
Add configurable large overlay image scale
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Nov 13, 2024
1 parent 0ac2162 commit 3316a10
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
13 changes: 13 additions & 0 deletions collective/behavior/relatedmedia/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def default_preview_scale_direction():
)


def default_gallery_large_image_scale():
return api.portal.get_registry_record(
"collective.behavior.relatedmedia.image_gallery_default_large_scale", default="large"
)


def default_titles_as_caption():
return api.portal.get_registry_record(
"collective.behavior.relatedmedia.show_titles_as_caption_default", default=False
Expand Down Expand Up @@ -208,6 +214,12 @@ class IRelatedMediaBehavior(model.Schema):
required=False,
)

large_image_scale = schema.Choice(
title=_("Gallery default scale for large overlay image"),
vocabulary="plone.app.vocabularies.ImagesScales",
defaultFactory=default_gallery_large_image_scale,
)

gallery_css_class = schema.Choice(
title=_("Gallery layout"),
description=_("Feel free to add/remove classes in your registry.xml"),
Expand Down Expand Up @@ -244,6 +256,7 @@ class IRelatedMediaBehavior(model.Schema):
"first_image_scale_direction",
"preview_scale",
"preview_scale_direction",
"large_image_scale",
"gallery_css_class",
"related_media_base_path",
],
Expand Down
5 changes: 3 additions & 2 deletions collective/behavior/relatedmedia/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def images(self):
first_img_scales = None
first_img_description = ""
first_img_uuid = ""
large_scale = getattr(rm_behavior, "large_image_scale", "large")
further_images = []
gallery = {}

Expand Down Expand Up @@ -114,7 +115,7 @@ def images(self):
or "thumbnail",
)
if scale:
large_scale_url = first_img_scales.scale("image", scale="large").url
large_scale_url = first_img_scales.scale("image", scale=large_scale).url
gallery[first_img_uuid] = dict(
url=large_scale_url,
tag=scale.tag(
Expand Down Expand Up @@ -142,7 +143,7 @@ def images(self):
)
uuid = img.UID()
if scale:
large_scale_url = scales.scale("image", scale="large").url
large_scale_url = scales.scale("image", scale=large_scale).url
gallery[uuid] = dict(
url=large_scale_url,
tag=scale.tag(css_class="img-fluid"),
Expand Down
7 changes: 7 additions & 0 deletions collective/behavior/relatedmedia/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ class IRelatedMediaSettings(Interface):
required=False,
)

image_gallery_default_large_scale = schema.Choice(
title=_("Gallery default large scale for overlay images"),
vocabulary="plone.app.vocabularies.ImagesScales",
default="large",
required=False,
)

image_gallery_default_preview_scale_direction = schema.Bool(
title=_("Default setting for cropping gallery images"),
default=False,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>3003</version>
<version>3004</version>
</metadata>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
</value>
</records>

<!-- NOTE: the relatedmediagallery Icon for TinyMCE.toolbar is added in upgrades.py -->
<!-- NOTE: the relatedimagesgallery Icon for TinyMCE.toolbar is added in upgrades.py -->

</registry>
9 changes: 9 additions & 0 deletions collective/behavior/relatedmedia/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,13 @@
handler=".upgrades.update_tinymce_settings"
/>

<upgradeDepends
title="Configurable large image overlay scale"
profile="collective.behavior.relatedmedia:default"
source="3003"
destination="3004"
import_steps="plone.app.registry"
run_deps="True"
/>

</configure>

0 comments on commit 3316a10

Please sign in to comment.