I have a flexible content field > repeater > wysiwyg field.
Not sure if this is possible at all, but how might I go about checking if the WYSIWYG field contains an image, and if so, display the first image from the field?
I would normally just make a new image field, but I am not allowed to add any new fields. So I have to obtain the image from the existing WYSIWYG field and present it separately.
If you need it in the same loop when you go through the repeater then you could try this:
preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $texthtml, $image);
echo $image['src'];
Where of course the $texthtml is your WYSIWYG field.
If you need it in the same loop when you go through the repeater then you could try this:
preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $texthtml, $image);
echo $image['src'];
Where of course the $texthtml is your WYSIWYG field.