Skip to content

Commit

Permalink
Fix focal point data being localized
Browse files Browse the repository at this point in the history
  • Loading branch information
SebCorbin authored and RealOrangeOne committed Jul 19, 2024
1 parent 5cc28ac commit 966f2df
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Changelog
* Fix: Prevent incorrect menu ordering when order value is 0 (Ben Dickinson)
* Fix: Fix dynamic image serve view with certain backends (Sébastien Corbin)
* Fix: Show not allowed extension in error message (Sahil Jangra)
* Fix: Fix focal point chooser when localization enabled (Sébastien Corbin)
* Docs: Remove duplicate section on frontend caching proxies from performance page (Jake Howard)
* Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz)
* Docs: Document Wagtail's bug bounty policy (Jake Howard)
Expand Down
1 change: 1 addition & 0 deletions docs/releases/6.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ This feature was developed by Albina Starykova and sponsored by The Motley Fool.
* Prevent incorrect menu ordering when order value is 0 (Ben Dickinson)
* Fix dynamic image serve view with certain backends (Sébastien Corbin)
* Show not allowed extension in error message (Sahil Jangra)
* Fix focal point chooser when localization enabled (Sébastien Corbin)

### Documentation

Expand Down
8 changes: 4 additions & 4 deletions wagtail/images/templates/wagtailimages/images/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<div
class="focal-point-chooser"
style="max-width: {{ rendition.width }}px; max-height: {{ rendition.height }}px;"
data-focal-point-x="{{ image.focal_point_x|default_if_none:'' }}"
data-focal-point-y="{{ image.focal_point_y|default_if_none:'' }}"
data-focal-point-width="{{ image.focal_point_width|default_if_none:'' }}"
data-focal-point-height="{{ image.focal_point_height|default_if_none:'' }}"
data-focal-point-x="{{ image.focal_point_x|default_if_none:''|unlocalize }}"
data-focal-point-y="{{ image.focal_point_y|default_if_none:''|unlocalize }}"
data-focal-point-width="{{ image.focal_point_width|default_if_none:''|unlocalize }}"
data-focal-point-height="{{ image.focal_point_height|default_if_none:''|unlocalize }}"
data-focal-input-label="{% trans 'Image focal point' %}"
>
<img {{ rendition.attrs }} decoding="async" data-original-width="{{ image.width|unlocalize }}" data-original-height="{{ image.height|unlocalize }}" class="show-transparency">
Expand Down
12 changes: 10 additions & 2 deletions wagtail/images/tests/test_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,12 +1264,20 @@ def test_reupload_different_name(self):
def test_no_thousand_separators_in_focal_point_editor(self):
large_image = Image.objects.create(
title="Test image",
file=get_test_image_file(size=(1024, 768)),
file=get_test_image_file(size=(3840, 2160)),
focal_point_x=2048,
focal_point_y=1001,
focal_point_width=1009,
focal_point_height=1002,
)
response = self.client.get(
reverse("wagtailimages:edit", args=(large_image.id,))
)
self.assertContains(response, 'data-original-width="1024"')
self.assertContains(response, 'data-original-width="3840"')
self.assertContains(response, 'data-focal-point-x="2048"')
self.assertContains(response, 'data-focal-point-y="1001"')
self.assertContains(response, 'data-focal-point-width="1009"')
self.assertContains(response, 'data-focal-point-height="1002"')

@override_settings(WAGTAILIMAGES_IMAGE_MODEL="tests.CustomImage")
def test_unique_together_validation_error(self):
Expand Down

0 comments on commit 966f2df

Please sign in to comment.