# break lines with \includegraphics[draft] option

When I am using \includegraphics with the draft option

\includegraphics[draft]{long-image-name}


the image name is shown instead of the image. Unfortunately it appears on one line without lines breaks, so that it extends to the beyond the border and becomes unreadable. Is it possible to fix this?

• That's \texttt, most likely, this doesn't break – user31729 May 30 '16 at 20:52

A horrible hack. But, hey! It works!

\documentclass{article}
\usepackage[draft]{graphicx}
\usepackage{xpatch}

\makeatletter
\patchcmd{\Gin@setfile}
{\edef\@tempa{#3}\rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}}
{\breitling@draftfilename{#3}}
{}{\ddt}
\ExplSyntaxOn
\tl_new:N \l_breitling_filename_tl
\NewDocumentCommand{\breitling@draftfilename}{m}
{
\tl_set:Nx \l_breitling_filename_tl { #1 }
\rlap{~\parbox{.9\Gin@req@width}{\small\ttfamily\raggedright
\tl_map_inline:Nn \l_breitling_filename_tl { ##1 \hspace{0pt} }
}}
}
\ExplSyntaxOff
\makeatother

\begin{document}