I'm not sure how I feel about some of this duplication. Is there any way to split out this logic to a common function where we just pass in a single jQuery object (`this` or `this.closest('.imageModal')`, presumably) and do all of the operations on that object?