When a file contains a <ref> inside its caption, the <ref> isn't counted or detected, and it doesn't appear in <references>. This can be seen at the start of the section "Beginning of the stampede" in http://parsoid-lb.eqiad.wikimedia.org/enwiki/Klondike_Gold_Rush?oldid=651957368.
It can also be tested on the command line:
echo "[[File:foo.jpg|A <ref>ref one</ref>]]" | node parse <p data-parsoid='{"dsr":[0,37,0,0]}'><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"A <ref>ref one</ref>"}],"dsr":[0,37,null,null]}' data-mw='{"caption":"A <ref>ref one</ref>"}'><a href="./File:Foo.jpg" data-parsoid='{"a":{"href":"./File:Foo.jpg"},"sa":{}}'><img resource="./File:Foo.jpg" src="//upload.wikimedia.org/wikipedia/commons/0/06/Foo.jpg" height="197" width="300" data-parsoid='{"a":{"resource":"./File:Foo.jpg","height":"197","width":"300"},"sa":{"resource":"File:foo.jpg"}}'/></a></span></p>