Sets the image source of a given HTMLImageElement by caching the image.

  • Parameters

    • url: string

      The URL of the image to cache.

    Returns { ref: (element: null | HTMLImageElement) => void }

    • A function that takes an HTMLImageElement as input and sets its source with the cached image.