Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $content = '<img whatever title="my title" whatever src="mysrc.jpg" whatever />';
- //replace title with alt
- $replaced = preg_replace('/(\<img.*?)title/', '$1alt', $content);
- //replace src with data-src
- $replaced = preg_replace('/(\<img.*?)src/', '$1data-src', $replaced);
- //add the rest
- $replaced = preg_replace('/(\<img.*?)\/\>/', '$1'.' '.'class=\'l-img artcl-img\' src=\'load.png\' />', $replaced);
- echo($replaced);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement