# Issues with grffile passing options to graphicx (draft/final)

I’ve been trying to set draft mode globally on my document, but I still want \includegraphics to work normally, so the graphicx package should receive the final option. I’m also using the grffile package.

I’ve found that with grffile, the final option for graphicx doesn’t work depending on how exactly the packages are loaded, so only the box with the filename is printed despite setting final. The following is what I’ve found out through experimentation:

% result: DRAFT
\documentclass[draft]{scrartcl}
\usepackage[final]{graphicx}
\usepackage{grffile}
\begin{document}
\end{document}

% result: DRAFT
\documentclass[draft]{scrartcl}
\usepackage{graphicx}
\usepackage[final]{grffile}
\begin{document}
\end{document}

% result: DRAFT
\documentclass[draft]{scrartcl}
\usepackage[final]{graphicx}
\usepackage[final]{grffile}
\begin{document}
\end{document}

% result: DRAFT
\documentclass[draft]{scrartcl}
\usepackage{grffile}
\usepackage[final]{graphicx}
\begin{document}
\end{document}

% result: FINAL
\documentclass[draft]{scrartcl}
\usepackage[final]{grffile}
\usepackage{graphicx}
\begin{document}
\end{document}

% result: FINAL
\documentclass[draft]{scrartcl}
\usepackage[final]{grffile}
\usepackage[final]{graphicx}
\begin{document}
\end{document}

So grffile must be loaded first, with the final option. Why is that? It would be much less error-prone if the whole thing didn’t depend on the order of the packages (how is an average user supposed to figure this out? Especially since grffile’s documentation uses examples in the “wrong” [in this case] order:

\usepackage[latin1]{inputenc}[2006/02/22]
% \usepackage[latin1]{inputenx}
\usepackage{graphicx}
\usepackage[encoding,filenameencoding=utf8]{grffile}

grffile documentation, section 1.4.3).

I assume it has something to do with the fact that grffile actually loads graphics instead of graphicx (there is no mention of the graphicx package in grffile):

grffile.sty v1.17 lines 76–78:

\DeclareDefaultOption{%
\PassOptionsToPackage\CurrentOption{graphics}%
}

grffile.sty v1.17 line 105:

\RequirePackage{graphics}

Using TeX Live 2016.