The background color behind the image should be white over the whole height of the box. Just the text has to be with the green background color. Is it possible to do it inside the box or only with another box just for the image?
\documentclass{article}
\usepackage[skins,hooks,xparse,breakable]{tcolorbox}
\usepackage{xcolor}
\usepackage{chngcntr}
\usepackage{blindtext}
\usepackage{tikz}
\usepackage{graphicx}
\newcounter{examplecounter}
\counterwithin{examplecounter}{section}
\usetikzlibrary{calc}
\definecolor{headercolourgreen}{rgb}{0,0.7019,0.7019}
\usepackage[
typ=ab,
fach=,
lerngruppe=,
farbig
% nummer=2A,
% datumAnzeigen,
% namensfeldAnzeigen,
]{schule}
\tcbset{MyStyle/.style={
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colback=white,
before skip={2em}, % increase spacing before the env
}}
\DeclareTColorBox{new}{O{}}{
MyStyle,
overlay unbroken and first={
% draw box on the left
\node[fill=headercolourgreen!5,
font=\color{headercolourgreen}\sffamily\bfseries\large,
anchor=south west,
xshift=2mm
] (titlebox) at (frame.north west)
{Exercise \refstepcounter{examplecounter}\theexamplecounter};
\draw[draw=headercolourgreen, line width=2pt]
(titlebox.north west-|frame.north west)--+(0,-1.5);
},
}
\DeclareTColorBox{aufgabeAux}{O{}}{
MyStyle,
overlay unbroken and first={
% draw box on the left
\node[fill=headercolourgreen!5,
font=\color{headercolourgreen}\sffamily\bfseries\large,
anchor=south west,
xshift=2mm
] (titlebox) at (frame.north west)
{Aufgabe \refstepcounter{aufgabe}\theaufgabe\ #1};
\draw[draw=headercolourgreen, line width=2pt]
(titlebox.north west-|frame.north west)--+(0,-1.5);
},
}
\pgfkeys{MyAufgabe/.cd,
subtitle/.store in=\MyAufgabeSubtitle,
}
\renewenvironment{aufgabe}[1][]{%
\pgfkeys{MyAufgabe/.cd, subtitle={}, #1}%
\begin{aufgabeAux}[\MyAufgabeSubtitle]%
}{%
\end{aufgabeAux}%
}%
\newlength\myheight
\newlength\mydepth
\settototalheight\myheight{Xygp}
\settodepth\mydepth{Xygp}
\newcommand*\inlinegraphics[1]{%
\settototalheight\myheight{Xygp}%
\settodepth\mydepth{Xygp}%
\raisebox{-\mydepth}{\includegraphics[height=\myheight]{#1}}%
}
\newcommand{\dpcalc}{\textbf{\inlinegraphics{example-image-b}\space}}
\author{}
\title{}
\date{\today}
\begin{document}
\begin{aufgabe}[subtitle=This is a subtitle \dpcalc]
This is an example of using the new \verb|aufgabe| environment with a subtitle.
This should have the title appear as the \verb|new| environment.
\end{aufgabe}
\end{document}