Give img a class automatically

I have a theme, where the links/menus are styled with borders&padding which look odd on pictures, therefore I tried to add the following to my functinos.php

function add_imgspecial_class_to_image_links($html, $attachment_id, $attachment) {

$linkptrn = “/<a[^>]*>/”;

$found = preg_match($linkptrn, $html, $a_elem);

// If no link, do nothing

if($found <= 0) return $html;

$a_elem = $a_elem[0];

// Check to see if the link is to an uploaded image

$is_attachment_link = strstr($a_elem, “wp-content/uploads/”:wink:;

// If link is to external resource, do nothing

if($is_attachment_link === FALSE) return $html;

if(strstr($a_elem, “class=””:wink: !== FALSE){ // If link already has class defined inject it to attribute

$a_elem_new = str_replace(“class=””, “class=”imgspecial “, $a_elem);

$html = str_replace($a_elem, $a_elem_new, $html);

}else{ // If no class defined, just add class attribute

$html = str_replace(“<a “, “<a class=”imgspecial” “, $html);

}

return $html;

}

add_filter(‘image_send_to_editor’, ‘add_imgspecial_class_to_image_links’, 10, 3);

Works fine in a single WP setup, but on WPMU, not so much.

I tried to change /wp-content/uploads to /files/, didn’t do the trick