Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter teso

    (@teso)

    This pulls in comment images and resizes Oembed Vimeo and Youtube in the comments RSS feed (sorry for the poor variables convention):

    function change_vimeo_width($contentwv) {
    if (is_comment_feed()) {
    $post_id = get_the_ID();
    		 	$comments = get_comments( $post_id );
    	   foreach ($comments as $comment) {
     $comment_id = get_comment_ID($comment);
     $contentwv = get_comment_text($comment_id);
     $retstringwv= 'width="269"';
     $retstringhv= 'height="auto"';
    	$patternwv = '(width=[\'\"](\d+)[\'\"])'; //pattern to look for
    	$patternhv = '(height=[\'\"](\d+)[\'\"])';
        if (false !== strpos($contentwv,"youtube")) {
           $replacedwidthv = preg_replace($patternwv, $retstringwv, $contentwv );
           return preg_replace($patternhv, $retstringhv, $replacedwidthv );
        } elseif (false !== strpos($contentwv,"vimeo")) {
           $replacedwidthv = preg_replace($patternwv, $retstringwv, $contentwv );
           return preg_replace($patternhv, $retstringhv, $replacedwidthv );
        } elseif (get_comment_meta($comment_id, 'comment_image', true)) {
            		$comment_image = get_comment_meta($comment_id, 'comment_image', true);
                    $output .= '
                    <img src="' . $comment_image['url'] . '" alt="" />
                    ';
                    $output .= '</div>
                    ';
                    $contentwv = $contentwv.$output;
        	return $contentwv;}
        }
        }
        return $contentwv;
    }
    add_filter('comment_text','change_vimeo_width');
Viewing 1 replies (of 1 total)