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

Code before:
    UsageCountColumn,
)
from wagtail.admin.utils import get_valid_next_url_from_request, set_query_params
from wagtail.admin.views import generic
from wagtail.images import get_image_model
from wagtail.images.exceptions import InvalidFilterSpecError
from wagtail.images.forms import URLGeneratorForm, get_image_form
from wagtail.images.models import Filter, SourceImageIOError
from wagtail.images.permissions import permission_policy
from wagtail.images.utils import generate_signature
from wagtail.models import ReferenceIndex, Site

permission_checker = PermissionPolicyChecker(permission_policy)

Image = get_image_model()

USAGE_PAGE_SIZE = getattr(settings, "WAGTAILIMAGES_USAGE_PAGE_SIZE", 20)


class ImagesFilterSet(BaseMediaFilterSet):
    permission_policy = permission_policy

    usage_count = django_filters.RangeFilter(
        field_name="usage_count",
        label=gettext_lazy("Usage count"),
        widget=django_filters.widgets.RangeWidget(
            attrs={
                "class": "w-field__input",
            },
        ),
        help_text=gettext_lazy("Filter images by their usage count range"),
    )

    class Meta:
        model = Image
        fields = []


class IndexView(generic.IndexView):
    ORDERING_OPTIONS = {
        "-created_at": gettext_lazy("Newest"),
        "created_at": gettext_lazy("Oldest"),
        "title": gettext_lazy("Title: (A -> Z)"),
        "-title": gettext_lazy("Title: (Z -> A)"),
        "file_size": gettext_lazy("File size: (low to high)"),
        "-file_size": gettext_lazy("File size: (high to low)"),
        "usage_count": gettext_lazy("Usage count: (low to high)"),
        "-usage_count": gettext_lazy("Usage count: (high to low)"),
    }
    default_ordering = "-created_at"
    context_object_name = "images"

Review comment (suggestion):
The range widget will add a dash `-` between the two inputs. Since we stack the inputs vertically, it looks a bit awkward. Maybe it's better to create a subclass of `SuffixedMultiWidget` and add placeholders to the inputs that indicate they are min/max inputs, similar to how we do it for date ranges:

https://github.com/wagtail/wagtail/blob/b808f4e08796e50d1d5dd20b71bd08e6344b7bfe/wagtail/admin/filters.py#L16-L34

Code after:
)
from wagtail.admin.utils import get_valid_next_url_from_request, set_query_params
from wagtail.admin.views import generic
from wagtail.images import get_image_model
from wagtail.images.exceptions import InvalidFilterSpecError
from wagtail.images.forms import URLGeneratorForm, get_image_form
from wagtail.images.models import Filter, SourceImageIOError
from wagtail.images.permissions import permission_policy
from wagtail.images.utils import generate_signature
from wagtail.models import ReferenceIndex, Site

permission_checker = PermissionPolicyChecker(permission_policy)

Image = get_image_model()

USAGE_PAGE_SIZE = getattr(settings, "WAGTAILIMAGES_USAGE_PAGE_SIZE", 20)


class ImagesFilterSet(BaseMediaFilterSet):
    permission_policy = permission_policy

    class Meta:
        model = Image
        fields = []


class IndexView(generic.IndexView):
    ORDERING_OPTIONS = {
        "-created_at": gettext_lazy("Newest"),
        "created_at": gettext_lazy("Oldest"),
        "title": gettext_lazy("Title: (A -> Z)"),
        "-title": gettext_lazy("Title: (Z -> A)"),
        "file_size": gettext_lazy("File size: (low to high)"),
        "-file_size": gettext_lazy("File size: (high to low)"),
        "usage_count": gettext_lazy("Usage count: (low to high)"),
        "-usage_count": gettext_lazy("Usage count: (high to low)"),
    }
    default_ordering = "-created_at"
    context_object_name = "images"
    permission_policy = permission_policy
    any_permission_required = ["add", "change", "delete"]
    model = Image
    filterset_class = ImagesFilterSet
    show_other_searches = True
    header_icon = "image"
    page_title = gettext_lazy("Images")
    add_item_label = gettext_lazy("Add an image")
    index_url_name = "wagtailimages:index"
    index_results_url_name = "wagtailimages:index_results"
    add_url_name = "wagtailimages:add_multiple"
    edit_url_name = "wagtailimages:edit"