diff --git a/wagtail/images/admin_urls.py b/wagtail/images/admin_urls.py index 3197f0a535..1ce0115603 100644 --- a/wagtail/images/admin_urls.py +++ b/wagtail/images/admin_urls.py @@ -39,7 +39,7 @@ urlpatterns = [ "chooser/results/", chooser.ChooseResultsView.as_view(), name="chooser_results" ), path( - "chooser//", + "chooser/chosen//", chooser.ImageChosenView.as_view(), name="image_chosen", ), diff --git a/wagtail/images/views/chooser.py b/wagtail/images/views/chooser.py index 80a822eab8..428ffd9dbb 100644 --- a/wagtail/images/views/chooser.py +++ b/wagtail/images/views/chooser.py @@ -17,6 +17,7 @@ from wagtail.admin.views.generic.chooser import ( ChooseResultsViewMixin, ChooseViewMixin, ChosenResponseMixin, + ChosenViewMixin, CreationFormMixin, ) from wagtail.admin.views.generic.permissions import PermissionCheckedMixin @@ -187,10 +188,10 @@ class ChooseResultsView( pass -class ImageChosenView(ImageChosenResponseMixin, View): - def get(self, request, image_id): - image = get_object_or_404(get_image_model(), id=image_id) - return self.get_chosen_response(image) +class ImageChosenView(ChosenViewMixin, ImageChosenResponseMixin, View): + def get(self, request, *args, pk, **kwargs): + self.model = get_image_model() + return super().get(request, *args, pk, **kwargs) def duplicate_found(request, new_image, existing_image):