How to get thumbnails in a list of figures?

To be honest, I'm not sure if I really want this because I can't imagine how exactly it would look. But maybe someone is interested in this, too, or even has already written code to achieve this: it might be practical or interesting to have small thumbnail previews of a figure in the list of figures next to the caption.

This has already been briefly discussed here List of figures: source below image caption? but without any result so if anybody wants to give it a shot or has already done so: yay! :)

See Heiko's answer for an example image of how this might look.

-

Macro \addtocontents allows something to put into the list of figures:

\begin{figure}
\includegraphics{myimage}
\caption{My figure caption}
\protect\centerline{%
\protect\includegraphics[width=.25\linewidth]{myimage}%
}%
}%
\end{figure}


Variant with vertically centered image between number of figure and caption text:

\documentclass{article}
\usepackage{graphicx}
\newlength{\lofthumbsize}
\setlength{\lofthumbsize}{2em}

\newif\iflofimage
\DeclareRobustCommand*{\lofimage}[2][]{%
\iflofimage
$\vcenter to \lofthumbsize{\vss% \hbox to \lofthumbsize{\hss\includegraphics[{width=\lofthumbsize,height=\lofthumbsize,keepaspectratio=true,#1}]{#2}\hss}% \vss}$%
\fi
\ignorespaces
}
\begin{document}
\lofimagetrue
\listoffigures
\lofimagefalse
\begin{figure}
\caption{\lofimage{foo}Hello World}
\end{figure}
\begin{figure}
\caption{\lofimage{bar}Foobar}
\end{figure}
\end{document}


This looks like this:

-
Wow, I didn't know it was this easy. I tried something like this: \newcommand{\figureincludegraphics}[2][\empty]{\ifthenelse{\equal{#1}{\empty}}{‌​\includegraphics{#2}}{\includegraphics[#1]{#2}}\addtocontents{lof}{\protect\cente‌​rline{\protect\includegraphics[width=\linewidth,height=5em,keepaspectratio=true]{‌​#2}}}} which works but looks pretty awful to be honest. Maybe instead of having a large picture above the respective LoF line, having one at the beginning of the line or between number and caption would look better. Is there a similarly easy way to achieve this? –  Christian Nov 15 '12 at 16:04
@Christian \leftline instead of \centerline puts the image at the beginning of the line. If \addtocontents is given after \caption, then the image is put below the respective LoF line. –  Heiko Oberdiek Nov 15 '12 at 16:08
No, \leftline doesn't work somehow :/ It does shift the image to the left but it's still in a separate line. –  Christian Nov 15 '12 at 18:20
Ok, your new code basically works as expected. Great :) I'll post a picture of the result tomorrow and when I find the time I will have to some polishing like a bounding box along both axes without messing up the alignment and a minimal vertical space between images. Right now, tall images touch each other and generally increase the linespread too much, which both doesn't look pretty. –  Christian Nov 16 '12 at 0:16
I added an example LoF to your answer. Obviously, the variance in the line heights is the main downer currently. In principle it looks almost surprisingly ok though I have to say. I'm astonished nobody ever did this as far as I know. If anybody wants to discuss whether this is a typographical disaster or actually a nice feature, I'd welcome your opinion. –  Christian Nov 16 '12 at 16:55