def generate_image_url(image, filter_spec):
cache_key = image_url_cache_key(image.id, filter_spec)
url = cache.get(cache_key)
if url:
return url
from wagtail.images.views.serve import generate_signature
signature = generate_signature(image.id, filter_spec)
url = reverse("wagtailimages_serve", args=(signature, image.id, filter_spec))
url += image.file.name[len("original_images/") :]
cache.set(cache_key, url)
return url