Change how wp-include functions work via template, please help!
-
According to this post if i want to change a built-in function’s behaviour, i need to:
?Copy and paste the desired function into my template’s functions.php file
?Rename it.
?Then add after that the following code:remove_filter('name_of_filter', 'name_of_function_to_change'); add_filter('name_of_filter', 'name_of_new_function');
I want to change the get_image_tag function inmedia.php so that width and height are removed.
So I’ve copy and pasted this into my functions.php file:
Note: this isn’t tweaked yet, i’ll do that after.<?php function mk_get_image_tag ($id, $alt, $title, $align, $size='medium') { list( $img_src, $width, $height ) = image_downsize($id, $size); $hwstring = image_hwstring($width, $height); $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id; $class = apply_filters('get_image_tag_class', $class, $id, $align, $size); $html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title).'" '.$hwstring.'class="'.$class.'" />'; $html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size ); return $html; } ?>
But this is the part where i get confused:
remove_filter('<strong>***********</strong>', 'get_image_tag'); add_filter('<strong>***********</strong>', 'mk_get_image_tag');
What does *********** refer too?
I’m totally confused about how that affects the outcome?!
Surely I just need to say:
replace this function with my function
Why do i have to do this with filters?Thanks a million.
- The topic ‘Change how wp-include functions work via template, please help!’ is closed to new replies.