Wordpress functions.php: Dodanie klasy fancyboxa

function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt = '' ){
$classes = 'fancy'; // separated by spaces, e.g. 'img image-link'
// sprawdzaj jezeli istenieje i zamien
if ( preg_match('/<a.*?>/', $html) ) {
$html = preg_replace('/(<a.*?.*?>)/', '$1 ' . $classes . '$2', $html);
} else {
$html = preg_replace('/(<a.*?)>/', '$1 >', $html);
}
return $html;
}
add_filter('image_send_to_editor','give_linked_images_class',10,8);