This corresponds to my test https://jsfiddle.net/oa62e1mz/, based on https://jsfiddle.net/6qvro0ua/, both mentioned in the comments of this answer to Fit <div> tightly around enclosed image?
. For this test, make sure that the first image has a caption on at least 2 lines and set the window width to get 2 + 1 images. Result: Only for the second image, there is a blank between the image and the caption.