How to provide attribution to a media source in a research paper?
Why don't you provide a list of media sources in the appendix similar to the obligatory literature list.
You number the images anyway inside the paper, so you can easily reference them in an appendix. Depending on your textprocessing tool you also can generate backlinks to the images for hypertext reading.
This could look like this:

Apendix C...
sources of media used in this paper
For detailed Information on Licences see [Link... creative commons, gnu, whatever...]

Figure 1 (p. 42) Apples, Takeaway (Own work) via Wikimedia, Licence CC-BY-SA 4.0
Figure 2 (p. 69) Oranges, Finsh, Ellen Levy (own work) via Wikimedia, Licence CC-BY-SA 3.0
Figure 2 (p. 104) Tree, Gimmel, Benjamin (own work) via Wikimedia, Licence CC-BY-SA 3.0