GIF Figures do not have numbers that can be used by `numref`
Describe the bug
We have just started to add GIFs to our docs and have noticed that, even though numfig=True, the PNG Figures have numbers, but the GIFs do not. We're just using the default StandaloneHTMLBuilder.
How to Reproduce
In any docs project, add a figure with a gif image. The caption does not have a Fig. number.
.. figure:: example.png
This image will have a number
.. figure:: example.gif
This image does not have a number
I tried adding a numref to the page, in case the number was generated but not displayed, and got the attached bug report. The error message assert target_node is not None suggested a number was expected but not found.
Environment Information
Platform: linux; (Linux-5.15.0-141-generic-x86_64-with-glibc2.35)
Python version: 3.12.10 (main, Apr 9 2025, 08:55:05) [GCC 11.4.0])
Python implementation: CPython
Sphinx version: 7.2.6
Docutils version: 0.20.1
Jinja2 version: 3.1.4
Pygments version: 2.18.0
Sphinx extensions
Additional context
Error report generated when attempting to use numref to reference the missing figure number.
Actually, sphinx has just decided that all my input files have changed and done a full rebuild. I now have Figure numbers, but I'm still getting the numref error. I've updated the title to reflect this.
Using your code in a fresh empty project created by sphinx-quickstart, with numfig = True in conf.py I can not reproduce the issue.
Same with using myst-parser and .md file. Please reduce your case to some minimal reproducer.