Get first image from page content?
Posted: Wed Feb 12, 2025 10:54 am
Folks,
for a photoblog-like scenario, I want to build a theme which, on the start page, displays a list of images linking to the corresponding post (which includes a short text and hashtags). My idea, for that, would be to modify this call...
<?php echo $page->content() ?>
... in the template to not just use the content() but actually get the first <img> tag from the content and ignore everything else.
Is that possible? More specifically, what structure does content() return? Especially given I'm using EasyMDE and so most likely markdown for editing pages?
Thanks very much and best regards,
Kristian
for a photoblog-like scenario, I want to build a theme which, on the start page, displays a list of images linking to the corresponding post (which includes a short text and hashtags). My idea, for that, would be to modify this call...
<?php echo $page->content() ?>
... in the template to not just use the content() but actually get the first <img> tag from the content and ignore everything else.
Is that possible? More specifically, what structure does content() return? Especially given I'm using EasyMDE and so most likely markdown for editing pages?
Thanks very much and best regards,
Kristian