You can achieve this with a user macro. Under Macros -> Edit Macros
, add this:
%SCRIPT
var tl = editor.document().textLines();
var regEx = /\\begin{figure}/;
var match
for (var i=0;i<tl.length;i++){
match = regEx.exec(tl[i]);
if (match) {
editor.document().foldBlockAt(false,i+1)
}
}
Test document
\documentclass{report}
\begin{document} % Level 1
\chapter{A} % Level 2
Test text.
\begin{figure} % Level 3
\includegraphics{example-image}
\end{figure}
\section{B} % Level 3
Test text.
\subsection{C} % Level 4
Test text.
\begin{figure}
\includegraphics{example-image}
\end{figure}
\section{D}
Test text.
\begin{figure}
\includegraphics{example-image}
\end{figure}
\subsection{E}
Test text.
\chapter{F}
Test text.
\begin{figure}
\includegraphics{example-image}
\end{figure}
\section{G}
Test text.
\section{H}
Test text.
\subsection{I}
Test text.
\paragraph{J}
Test text.
\begin{figure}
\includegraphics{example-image}
\end{figure}
\chapter{K}
Test text.
\end{document}
Note that the \chapter
, \section
etc. titled A
to K
have not been collapsed (Test text
in each block are still visible after executing the macro.
GIF

** If you want the expand figures
macro as well, replace editor.document().foldBlockAt(false,i+1)
in the above script with editor.document().expandParents(i+1)
, and save it as a separate macro.
As for the Level 1
to Level 4
blocks, I tried illustrating that with the test document above (see comments). Basically, it's not a fixed map of Level 1 -> Chapter
, Level 2 -> Section
etc.
Level 1
is just the first block that TeXstudio encounters that can be collapsed that is not already a sub-block of another. In most cases, this is the \begin{document}
command.
Level 2
blocks are nested within Level 1
blocks, usually \chapter
or \section
depending on document class, but not nested within other blocks.
and so on.
But you can see from the first figure environment in my example, which is nested within the \chapter
block, is considered to be the same level as the \section
block because both of them are nested within \chapter
.
Addendum
You wanted it to be added under the Collapse
submenu, but since you can activate these macros much quicker via keyboard shortcut (Shift+F1, etc. by default), so I didn't see the necessity to do so in my answer. This is possible, in general, and I might come back to do this eventually, just for fun.
Another possibility is to combine the collapse
and expand
into a single macro, and have it operate like the toggle comment
shortcut (Ctrl+T), which should be fun to do as well.