Guest User

Untitled

a guest
Jan 18th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <script src="https://unpkg.com/lazysizes@4.0.1/lazysizes.js"></noscript>
  2.  
  3. function add_responsive_class($content){
  4.  
  5. $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
  6. $document = new DOMDocument();
  7. libxml_use_internal_errors(true);
  8. $document->loadHTML(utf8_decode($content));
  9.  
  10. $imgs = $document->getElementsByTagName('img');
  11. foreach ($imgs as $img) {
  12. $img->setAttribute('class','img-responsive');
  13. }
  14.  
  15. $html = $document->saveHTML();
  16. return $html;
  17. }
Add Comment
Please, Sign In to add comment