The excellent answer by Ulrike unfortunately does not work any more e.g. for an existing file like example-image-a, because in the last years the graphicx package improved and its code was changed e.g. to support spaces in the names. Following Ulrike's idea of taking the definition of \Ginclude@graphics in graphics.sty, I tried to get a new version of the \imagetest command. I believe it is worth to share it.
\documentclass[]{article}
\usepackage{graphicx}
\graphicspath{{Figures/}}
\makeatletter
\newif\ifgraphicexist
\catcode\*=11 \newcommand\imagetestNew[1]{% \begingroup \global\graphicexisttrue \ifx\detokenize\@undefined\else \edef\Gin@extensions{\detokenize\expandafter{\Gin@extensions}}% \fi \let\input@path\Ginput@path \set@curr@file{#1}% \expandafter\filename@parse\expandafter{\@curr@file}% \ifx\filename@ext\Gin@gzext \expandafter\filename@parse\expandafter{\filename@base}% \ifx\filename@ext\relax \let\filename@ext\Gin@gzext \else \edef\Gin@ext{\Gin@ext\Gin@sepdefault\Gin@gzext}% \fi \fi \ifx\filename@ext\relax \@for\Gin@temp:=\Gin@extensions\do{% \ifx\Gin@ext\relax \Gin@getbase\Gin@temp \fi}% \else \Gin@getbase{\Gin@sepdefault\filename@ext}% \ifx\Gin@ext\relax \global\graphicexistfalse \let\Gin@savedbase\filename@base \let\Gin@savedext\filename@ext \edef\filename@base{\filename@base\Gin@sepdefault\filename@ext}% \let\filename@ext\relax \@for\Gin@temp:=\Gin@extensions\do{% \ifx\Gin@ext\relax \Gin@getbase\Gin@temp \fi}% \ifx\Gin@ext\relax \let\filename@base\Gin@savedbase \let\filename@ext\Gin@savedext \fi \fi \ifx\Gin@ext\relax \global\graphicexistfalse \def\Gin@base{\filename@area\filename@base}% \edef\Gin@ext{\Gin@sepdefault\filename@ext}% \fi \fi \ifx\Gin@ext\relax \global\graphicexistfalse \else \@ifundefined{Gin@rule@\Gin@ext}% {\global\graphicexistfalse}% {}% \fi \ifx\Gin@ext\relax \gdef\imageextension{unknown}% \else \xdef\imageextension{\Gin@ext}% \fi \endgroup \ifgraphicexist \expandafter \@firstoftwo \else \expandafter \@secondoftwo \fi } \catcode*=12
\makeatother
\begin{document}
\imagetestNew{example-image-a}{Yes, \imageextension}{No, \imageextension}
\imagetestNew{song.mp3}{Yes, \imageextension}{No, \imageextension}
\imagetestNew{fail}{Yes, \imageextension}{No, \imageextension}
\imagetestNew{failxxx.eps}{Yes, \imageextension}{No, \imageextension}
\imagetestNew{bib.bib}{Yes, \imageextension}{No, \imageextension}
Test using \texttt{graphicspath}:
% The file "using-graphicspath.png" is in the "Figures/" folder in the directory of this file
\imagetestNew{using-graphicspath.png}{Yes, \imageextension}{No, \imageextension}
\imagetestNew{OtherFolder/using-graphicspath.png}{Yes, \imageextension}{No, \imageextension}
\end{document}
Disclaimer: I have the feeling some lines between \begingroup and \endgroup are not really needed to this command. Still, not being sure whether it might have side effects removing them, I decided to leave them. If somebody feels like improving the code above, just go ahead!
Edit:
The previous code was actually breaking down when trying to use it with files that were in folders specified via the \graphicspath command or with file paths. This should be now fixed and the MWE has been made more general.
draftoption for your documentclass to have empty boxes instead of the picture itself. – Count Zero Feb 20 '13 at 11:48