<?php $sadrzaj = '<p>asdasdasds</p><p><a href="http://www.example.com/wp-content/uploads/2018/11/image.jpg" itemprop="url" title="some title"><img alt="some alt title" class="alignnone not-size-full wp-image-243618" src="http://www.example.com/wp-content/uploads/2018/11/image.jpg" width="940" height="529"></a></p>asdasdasd<p>asdasd</p><h3>asdada</h3><p><a href="http://www.example.com/wp-content/uploads/2018/11/image_02.jpg" itemprop="url" title="some title 02"><img alt="some alt title 02" class="alignnone size-full wp-image-243653" src="http://www.example.com/wp-content/uploads/2018/11/image_02.jpg" width="940" height="529"></a></p><h3>asdasd</h3>'; function to_je_to($content){ preg_match_all('/<img[^>]+>/', $content, $images); print_r($images); if(!is_null($images)){ foreach($images[0] as $index => $value){ if(preg_match('/class="[^"]* size-full[ "]/', $value)){ $new_img = str_replace('<img', '<img data-example', $value); $content = preg_replace('/' . preg_quote($value, '/') . '/', $new_img, $content); } } } return $content; // return no difference } echo to_je_to($sadrzaj);
You have javascript disabled. You will not be able to edit any code.