You can use the caption package to set up a style, lets call it overlay that saves the caption for use later. Here is an example:
EDIT example technique slightly change, example extended, now working with hyperref

\documentclass{article}
\usepackage{tikz,caption}
\usepackage{hyperref}
\usetikzlibrary{calc}
\DeclareCaptionFormat{overlay}{\gdef\capoverlay{#1#2#3\par}}
\DeclareCaptionStyle{overlay}{format=overlay}
\begin{document}
\begin{figure}[htp]
\centering
\captionsetup{format=overlay}
\caption{Example.}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=\linewidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[white, fill=gray,opacity=0.5] (0,0) rectangle (1,0.15);
\draw let \p1 = (1,0)
in node[opacity=0.5,text width=\x1,align=center,color=white] at
(0.5, 0.075)
{\capoverlay};
\end{scope}
\end{tikzpicture}
\label{fig:example}
\end{figure}
\begin{figure}[htp]
\centering
\includegraphics[width=3cm]{example-image-a}
\caption{Non-overlay example}
\label{fig:non}
\end{figure}
\begin{figure}[htp]
\centering
\captionsetup{format=overlay}
\caption{Example with caption overlay and long placed on a smaller figure.}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0)
{\includegraphics[width=0.7\linewidth]{example-image-a}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[white, fill=gray,opacity=0.5] (0,0) rectangle (1,0.15);
\draw let \p1 = (1,0)
in node[opacity=0.5,text width=\x1,align=center,color=blue] at
(0.5, 0.075)
{\capoverlay};
\end{scope}
\end{tikzpicture}
\label{fig:example2}
\end{figure}
A reference to Figure~\ref{fig:example} and to Figure~\ref{fig:example2}.
\listoffigures
\end{document}
Note this needs the caption to come before the tikz code. It formats the caption, saves it in a command and reuses that command in the code of the linked question to place text on top of the figure. As set-up now this works with hyperref and does not affect other figures. You can change the formatting of the caption via standard tikz commands on the node.