How to change src to data-src for iframe inside WP content? – WordPress Website Design Article

I need to change src to data-src for iframes inside WordPress content and add class lazy. I was trying this: function iframe_image_lazy_load($the_content) { $thecontent = get_the_content(); if(!empty($thecontent)) { libxml_use_internal_errors(true); $post = new DOMDocument(); $post->loadHTML(mb_convert_encoding($the_content, ‘HTML-ENTITIES’, ‘UTF-8’)); $iframes = $post->getElementsByTagName(‘iframe’); foreach( $iframes as $iframe ) { if( $iframe->hasAttribute(‘data-src’) ) continue; $clone = $iframe->cloneNode(); $src = $iframe->getAttribute(‘src’); $iframe->removeAttribute(‘src’); $iframe->setAttribute(‘data-src’, $src); $srcset = $iframe->getAttribute(‘srcset’); $iframe->removeAttribute(‘srcset’); if( ! empty($srcset)) { $iframe->setAttribute(‘data-srcset’,… This is only a snippet of a WordPress Website Design Article written by…

Read More

htaccess – WordPress Multisite query parameters – WordPress Website Design Article

Am currently having an issue with the redirection of query parameters on a multisite. I have embedded an Angular App inside an iframe and have a script to assign the query parameters of the app to the host page (deeplinking). The issue here is, the WP multisite redirects the assigned iframe query parameters to host page back to the main embed app page instead and hence, users are forced to restart their in-app journey. Could this be related to multisite…

Read More