I would like to update the_content_rss in WordPress so it would fit feedburner. It would need to find every img tag, see if it has a width and height set. If they are larger than 600 they should be reduced to 600. If they are not set, then width should be set to 600. I thought of using some of the code here to do it, but I got a bit stuck, I would appreciate help with fixing it.
Questions:
- Does it work?
How can it find if width is null - and in which case to add it?
<?php function feedburner_img_resize($the_content) { // Create a new istance of DOMDocument $post = new DOMDocument(); // Load $the_content as HTML $post->loadHTML($the_content); // Look up for all the <img> tags. $imgs = $post->getElementsByTagName('img'); // Iteration time foreach( $imgs as $img ) { // if width is smaller than 600 - no need to continue $width = $img->getAttribute('width'); if( $width < 600 ) continue; $img->removeAttribute('width'); $img->setAttribute('width', 600); $img->removeAttribute('height'); // so the image is not distorted }; return $post->saveHTML(); } add_filter('the_content_rss', 'feedburner_img_resize'); ?>
In function.php add the following function:
In a place where the need conclusion miniatures, write the following, changing the size of the thumbnails on the right for you: