Might be worth caching the outerHTML instead of the image element as that seems to be all we're using. It would cut down on repetition as well.