Q:

Clearing floats in LaTeX

I'm making a document using the memoir theme. In my document, I wish to have images floated to the left or the right at times.
I've got this working reasonably well:
\documentclass[twoside]{memoir}
\usepackage[papersize={8.5in,11in}, vmargin=0.5in, outer=1in, inner=0.5in, includehead, includefoot]{geometry}
\usepackage{color}
\usepackage{fontspec}
\usepackage{newunicodechar}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage[none]{hyphenat}
\usepackage{graphicx}
\usepackage{wrapfig}
\graphicspath{ {images/} }

\makeatletter

\newcommand\floatingimage[4]{
  \begin{wrapfigure}{#3}{0.25\textwidth}%
    \vspace{-20pt}%
    \begin{center}%
      \includegraphics[width=0.25\textwidth]{#1}%
    \end{center}%
    \vspace{-15pt}%
    \legend{#4}%
    \vspace{-15pt}%
  \end{wrapfigure}%
}

% Remove 'Figure 1' text
\patchcmd{\legend}%Cmd
    {\normalsize}%Search
    {\small\bfseries\raggedright}%Replace
    {}%Success
    {}%Fail

% Custom section heading
\newcommand{\beginsection}[1]{%
  \let\@section@title@\relax
  \normalfont\large\bfseries #1
  \normalfont\normalsize
  \par
  \vspace{0.5pt} % Required for vertical alignment, not quite sure why it's necessary

  \gdef\@section@title@{#1}
}

\makeatother

\setlength{\parindent}{0pt}%
\nonzeroparskip

\begin{document}
\chapterstyle{scp}
\chapter{Example}
\floatingimage{800placeholder}{800}{R}{Figure A}
\beginsection{Section 1}
\lipsum[1-1]

\beginsection{Section 2}
\lipsum[2-2]

\floatingimage{150placeholder}{150}{L}{Figure B}
\lipsum[3-3]

\beginsection{Section 3}
\lipsum[4-4]

\end{document}

The only thing is, I don't like the way the 'Section 3' heading is pushed inwards. I'd like instead for headings to appear after the floated element, at the start of a line. Ideally I would like for this behaviour to only apply when the float is on the left, as floats on the right don't push the titles.
In CSS I could accomplish this using h3 { clear: left; }. What's the LaTeX equivalent?
I did some searching and found \FloatBarrier in the placeins package, but this didn't change the output at all. Here's how I tried to use it.
\documentclass[twoside]{memoir}
\usepackage[papersize={8.5in,11in}, vmargin=0.5in, outer=1in, inner=0.5in, includehead, includefoot]{geometry}
\usepackage{color}
\usepackage{fontspec}
\usepackage{newunicodechar}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage[none]{hyphenat}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{placeins}
\graphicspath{ {images/} }

\makeatletter

\newcommand\floatingimage[4]{
  \begin{wrapfigure}{#3}{0.25\textwidth}%
    \vspace{-20pt}%
    \begin{center}%
      \includegraphics[width=0.25\textwidth]{#1}%
    \end{center}%
    \vspace{-15pt}%
    \legend{#4}%
    \vspace{-15pt}%
  \end{wrapfigure}%
}

% Remove 'Figure 1' text
\patchcmd{\legend}%Cmd
    {\normalsize}%Search
    {\small\bfseries\raggedright}%Replace
    {}%Success
    {}%Fail

% Custom section heading
\newcommand{\beginsection}[1]{%
  \let\@section@title@\relax
  \FloatBarrier
  \normalfont\large\bfseries #1
  \normalfont\normalsize
  \par
  \vspace{0.5pt} % Required for vertical alignment, not quite sure why it's necessary

  \gdef\@section@title@{#1}
}

\makeatother

\setlength{\parindent}{0pt}%
\nonzeroparskip

\begin{document}
\chapterstyle{scp}
\chapter{Example}
\floatingimage{800placeholder}{800}{R}{Figure A}
\beginsection{Section 1}
\lipsum[1-1]

\beginsection{Section 2}
\lipsum[2-2]

\floatingimage{150placeholder}{150}{L}{Figure B}
\lipsum[3-3]

\beginsection{Section 3}
\lipsum[4-4]
\end{document}

(Not going to attach a screenshot as it looks identical to the one above)
How can I achieve the effect I'm after?
EDIT: I found this related question but I can't get their solution working for me.

A:

With some care you can clear wrapfig's settings so the later text is not indented, although you need to add the extra space to compensate. (If you were doing this often you could automate the measurement of the image and the size of the paragraph, but not really worth it for a hand written docuemnt, only for an automated workflow)
Note wrapfig, even with L rather than l isn't really a latex float so the question title is a bit misleading.  I used \section as the custom definition seemed to miss all the important code for a section heading (controlling page breaks after the heading for example)
Also added some missing % and used \centering (which adds no vertical space) rather than center with negative space adjustments.

\documentclass[twoside]{memoir}
\usepackage[papersize={8.5in,11in}, vmargin=0.5in, outer=1in, inner=0.5in, includehead, includefoot]{geometry}
\usepackage{color}
\usepackage{fontspec}
\usepackage{newunicodechar}
\usepackage[nopar]{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage[none]{hyphenat}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{placeins}
\graphicspath{ {images/} }

\makeatletter

\newcommand\floatingimage[4]{%
  \begin{wrapfigure}{#3}{0.25\textwidth}%
\centering
      \includegraphics[width=0.25\textwidth]{#1}%

    \legend{#4}%
  \end{wrapfigure}%
}

% Remove 'Figure 1' text

\makeatother

\setlength{\parindent}{0pt}%
\nonzeroparskip

\begin{document}
\chapterstyle{scp}
\chapter{Example}
\floatingimage{example-image-a}{800}{R}{example-image-a}
\section{Section 1}
\lipsum[1-1]

\section{Section 2}
\lipsum[2-2]

\floatingimage{example-image-b}{150}{l}{example-image-b}
\lipsum[3-3]

\makeatletter
\WF@@everypar{}
\vspace{\baselineskip}
\makeatother

\section{Section 3}
\lipsum[4-4]
\end{document}

