def staticfiles_url_fetcher(url):
    """
    Returns the file matching url.

    This method will handle any URL resources that rendering HTML requires
    (eg: images pointed my ``img`` tags, stylesheets, etc).

    The default behaviour will fetch any http(s) files normally, and will
    also attempt to resolve staticfiles internally (this should mostly
    affect development scenarios, but also works if static files are served
    under a relative url).

    Returns a dictionary with two entries: ``string``, which is the
    resources data as a string and ``mime_type``, which is the identified
    mime type for the resource.
    """
    if url.startswith('/'):
        base_url = staticfiles_storage.base_url
        filename = url.replace(base_url, '', 1)

        path = finders.find(filename)
        if path:
            # This should match most cases. Manifest static files with relative
            # URLs will only be picked up in DEBUG mode here.
            with open(path, 'rb') as f:
                data = f.read()
        else:
            # This should just match things like Manifest static files with
            # relative URLs. While this code path will expect `collectstatic`
            # to have run, it should only be reached on if DEBUG = False.

            # XXX: Only Django >= 2.0 supports using this as a context manager:
            f = staticfiles_storage.open(filename)
            data = f.read()
            f.close()

        return {
            'string': data,
            'mime_type': mimetypes.guess_type(url)[0],
        }
    else:
        return default_url_fetcher(url)
Returns the file matching url.

    This method will handle any URL resources that rendering HTML requires
    (eg: images pointed my ``img`` tags, stylesheets, etc).

    The default behaviour will fetch any http(s) files normally, and will
    also attempt to resolve staticfiles internally (this should mostly
    affect development scenarios, but also works if static files are served
    under a relative url).

    Returns a dictionary with two entries: ``string``, which is the
    resources data as a string and ``mime_type``, which is the identified
    mime type for the resource.