Finds the first img tag in a rendered HTML string and returns the src attribute. This function can be used to extract the first image form a block variable to be used separately in any other place like a teaser section of a page card in a pagelist.
@{ +main | findFirstImage }
To get the first image of a Markdown variable, the markdown functions has to be applied before.
@{ text | markdown | findFirstImage }
Example
One use case for this function is to render short previews of pages in a pagelist in order to create overview pages for blog posts.
<@ foreach in pagelist @>
<a href="@{ url }">
<h3>@{ title }</h3>
<p>@{ +main | findFirstParagraph }</p>
<@ with @{ +main | findFirstImage } { width: 500 } @>
<img src="@{ :fileResized }" />
<@ end @>
</a>
<@ end @>