loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); foreach ($dom->getElementsByTagName('img') as $img) { // list($width, $height) = getimagesize( $_SERVER['DOCUMENT_ROOT'].urldecode($img->getAttribute('src'))); list($width, $height) = getimagesize( "/users/cwsvjudo/www/".urldecode($img->getAttribute('src'))); $img->setAttribute('width', $width); $img->setAttribute('height', $height); } return $dom->saveXML(); } # Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication # http://creativecommons.org/publicdomain/zero/1.0/ function ampify($html='') { // $html = addImgSize($html); # Replace img, audio, and video elements with amp custom elements $html = str_ireplace( ['',''], ['',''], $html ); # Add closing tags to amp-img custom element $html = preg_replace('//', '',$html); # Whitelist of HTML tags allowed by AMP $html = strip_tags($html,'