Function to resize images from their data attributes