Adding the swap functionality to images