Repository: wagtail/wagtail
File: wagtail/images/views/images.py (Python)

Code before:
        )

    def get_filterset_kwargs(self):
        kwargs = super().get_filterset_kwargs()
        kwargs["is_searching"] = self.is_searching
        return kwargs

    def get_next_url(self):
        next_url = self.index_url
        request_query_string = self.request.META.get("QUERY_STRING")
        if request_query_string:
            next_url += "?" + request_query_string
        return next_url

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        view_mode = self.request.GET.get("view", "grid")

        context.update(
            {
                "next": self.get_next_url(),
                "current_collection": self.current_collection,
                "current_ordering": self.ordering,
                "ORDERING_OPTIONS": self.ORDERING_OPTIONS,
                "view_mode": view_mode,
            }
        )

        return context


class EditView(generic.EditView):
    permission_policy = permission_policy
    pk_url_kwarg = "image_id"
    error_message = gettext_lazy("The image could not be saved due to errors.")
    template_name = "wagtailimages/images/edit.html"
    index_url_name = "wagtailimages:index"
    edit_url_name = "wagtailimages:edit"
    delete_url_name = "wagtailimages:delete"
    url_generator_url_name = "wagtailimages:url_generator"
    header_icon = "image"
    context_object_name = "image"

    @cached_property
    def model(self):
        return get_image_model()

    def get_form_class(self):
        return get_image_form(self.model)


Review comment (bug):
Need tests that confirm:

- the view mode is passed correctly
- the listings’ HTML are adapted based on the view mode

From Sage: need tests that would fail if they ran against the previous implementation of those listings (so demonstrate the changes add this new behavior).

---

Assert contents of title column with title + filename (below title), matching the test’s created image

Code after:

    def get_add_url(self):
        # Pass the collection filter to prefill the add form's collection field
        return set_query_params(
            super().get_add_url(),
            {"collection_id": self.current_collection and self.current_collection.pk},
        )

    def get_filterset_kwargs(self):
        kwargs = super().get_filterset_kwargs()
        kwargs["is_searching"] = self.is_searching
        return kwargs

    def get_next_url(self):
        next_url = self.index_url
        request_query_string = self.request.META.get("QUERY_STRING")
        if request_query_string:
            next_url += "?" + request_query_string
        return next_url

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        context.update(
            {
                "next": self.get_next_url(),
                "current_collection": self.current_collection,
                "current_ordering": self.ordering,
                "ORDERING_OPTIONS": self.ORDERING_OPTIONS,
                "layout": self.layout,
            }
        )

        return context

    @cached_property
    def layout(self):
        return self.request.GET.get("layout", "grid")

    @cached_property
    def columns(self):
        if self.layout == "grid":
            return []
        else:
            columns = [
                BulkActionsColumn("bulk_actions"),
                ImagePreviewColumn(
                    "preview",
                    label=_("Preview"),
                    accessor="image",
                    classname="image-preview",