[Tex/LaTex] Image placeholder as in \includegraphics[draft], but without path appearing

graphics

I want to upload a talk slides to a repository where all material submitted shall be under a certain license. For this, I need to exclude certain images present in the actually sued slides for which the license does not apply, adn have a placeholder instead.
\includegraphics[draft,.. pretty much does what I want, only that the actual command in my document is something like

\includegraphics[draft,widht=0.7\textwidth]{../../../talks/1999/acapulco/filename}

which results in the full path being displayed in, and exceeding the placeholder box.

Can I somehow prevent the path from being displayed? It is both ugly and contains more information than I want to convey. Filename alone would be ok, but is not required. If I remove \includegraphics entirely, the layout changes and/or I would have to manually size and place the placeholder.

Best Answer

Here's a solution that adds a noincl key:

\documentclass{article}

\usepackage{graphicx,etoolbox}

\makeatletter
\define@key{Gin}{noincl}[true]{%
  \lowercase{\Gin@boolkey{#1}}{draft}%
  \lowercase{\Gin@boolkey{#1}}{noincl}%
}
\newif\ifGin@noincl

\patchcmd{\Gin@setfile}{\hb@xt@}{\noinc@box{#3}}{}{}

\def\noinc@box#1#2#3{%
  \ifGin@noincl
    \do@noinc@box{#1}{#2}{#3}%
  \else
    \hb@xt@#2{#3}
  \fi
}

\def\do@noinc@box#1#2#3{%
  \hb@xt@\Gin@req@width{%
    \vrule\hss
    \vbox to \Gin@req@height{%
      \hrule \@width \Gin@req@width
      \vss
      \edef\@tempa{#1}%
      \expandafter\filename@parse\expandafter{\@tempa}%
      \rlap{%
        \kern3\p@
        \parbox{\dimexpr\Gin@req@width-6\p@}{
          \raggedright\footnotesize Not included for copyright reasons
        }%
      }%
      \vss
      \rlap{\kern3\p@ \tiny\ttfamily\filename@base.\filename@ext}%
      \vss
      \hrule}%
    \hss\vrule}%
}
\makeatother

\begin{document}

\includegraphics[noincl,width=4cm]{/usr/local/texlive/2014/texmf-dist/tex/latex/mwe/example-image.pdf}

\end{document}

enter image description here