WordPress.org

Forums

WP-RecentComments
function rc_get_avatar_url fails on some html (2 posts)

  1. patrik.hultgren
    Member
    Posted 3 years ago #

    Hi there!

    When the $code variable has this value, then the function rc_get_avatar_url($code) won´t work. The alt, width and height attributes will still remain in the return value.

    <img src="http://dev.sjukhuslakaren.se/wp-content/uploads/userphoto/8.thumbnail.jpg" alt="Mikael Rolfs" width="80" height="60" class="photo" />

    To solve the problem, I added this code:

    function rc_get_avatar_url($code) {
    
    	//MY FIX - START
    	$quotes = array('"', "'");
    
    	foreach ($quotes as $q) {
    
    		$pos_start = strpos($code, $q.'http');
    		$pos_end = strpos($code, $q, $pos_start + 1);
    
    		if ($pos_start !== false && $pos_end !== false) {
    
    			$src = substr($code, $pos_start + 1, $pos_end - $pos_start - 1);
    			$src = preg_replace(array('/&/i'), array('&'), $src);
    			return $src;
    		}
    	}
    	//MY FIX - END
    
    	return preg_replace(array('/^.+(src=)(\"|\')/i', '/(\"|\')\sclass=(\"|\').+$/i', '/&/i'), array('', '', '&'), $code);
    }

    Could this be added to the official version? Or maybe be done in a bettar way?

    Best Regards
    Patrik Hultgren

    http://wordpress.org/extend/plugins/wp-recentcomments/

  2. dctabuyz
    Member
    Posted 2 years ago #

    fix this bug plz

    function rc_get_avatar_url($code)
    {
            $code = preg_replace('/(&#(x0*26|0*38);)/i', '&', $code);
    
            if ( preg_match('/src=([\'"]*)([^\'"]+)\1/', $code, $matches) )
            {
                    return $matches[2];
            }
    
            return "";
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-RecentComments
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic