That’s great cyberbrain! Big up yourself!
I really haven’t got a clue when it comes to php, and until I get a chance to sit down and play around with it properly I’m totally at the mercy of others. Luckily however, a friend of mine wrote me this snippet of code to do the job, and it works perfectly.
function get_first_image_url($html)
{
if (preg_match(‘/<img.+?src=“(.+?)”/’, $html, $matches)) {
return $matches[1];
}
else return ‘url_of_default_image_if_post_has_no_img_tags.jpg’;
}
I then add the line:
<?php echo ‘<img src="’ .get_first_image_url($item->get_content()). ‘"/>’; ?>
into my HTML code and voila it works a treat. Don’t understand fully how it works, but I’m working on that. ![]()
I do have another problem now tho, which you may be able to shed some light on. I’d like to print out the start of the content of the post, but only the first sentence. Completely at a loss on that… I guess I need to parse the XML document up until the first ‘.’, then put that into a new string, something like $first_sentence, then i can echo $first_sentence… Yeah, that’s about as far as I’ve gotten. ![]()
Any help would be great.
![]()