I'm not sure if this is possible only with preg_replace
function but I would like to get only the first image and ignore all the other.
This code excludes all images in the text I want to display, but I need to get only the first image.
if (!$params->get('image')) {
$item->introtext = preg_replace('/<img[^>]*>/', '', $item->introtext);
}
Can you please point me to the right direction to achieve this?
EDIT :
It seems that using the limit
property is not enough since I don't want to skip the 1st image and keep the remaining. I need the opposite: Keep the 1st image and replace all the others.