Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. <?php
  2. $content = '<img whatever title="my title" whatever src="mysrc.jpg" whatever />';
  3.  
  4. //replace title with alt
  5. $replaced = preg_replace('/(\<img.*?)title/', '$1alt', $content);
  6.  
  7. //replace src with data-src
  8. $replaced = preg_replace('/(\<img.*?)src/', '$1data-src', $replaced);
  9.  
  10. //add the rest
  11. $replaced = preg_replace('/(\<img.*?)\/\>/', '$1'.' '.'class=\'l-img artcl-img\' src=\'load.png\' />', $replaced);
  12.  
  13. echo($replaced);
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement