Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

right now my images are outputting like this when I add them to my posts:

<a rel="highslide" class="highslide" href="http://domain.com/news/1013/filename.png"><img src="http://domain.com/news/1013/filename.png" alt="" width="200" height="279" class="aligncenter size-full wp-image-31055" /></a>

I am using this code to add the highslide rel and class attributes to the image:

    function add_highslide_attr( $html ) {
    preg_match_all('/(<a[^>]*>)(.*)/i', $html, $result);

    if( !isset($result) || !isset($result[1][0]) || ! $result[1][0] )
        return $html;

    $anchor = $result[1][0];

    if( strstr($anchor, 'rel=') )
        $anchor = str_replace('rel="', 'rel="highslide ', $anchor);
    else
        $anchor = str_replace('href=', 'rel="highslide" href=', $anchor);

    if( strstr($anchor, 'class=') )
        $anchor = str_replace('class="', 'class="highslide ', $anchor);
    else
        $anchor = str_replace('href=', 'class="highslide" href=', $anchor);

    $html = $anchor . $result[2][0];

    return $html;
}
add_filter( 'image_send_to_editor', 'add_highslide_attr', 10 );

I was wondering if anyone knew how to remove the class part and its attributes from the image tag (the class="aligncenter size-full wp-image-31055" part). It would also be cool to remove "domain.com" as well. I've researched this issue for several hours now and the code I've found hasn't worked, so I thought I would ask here. Thank you!

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.