Title: Adding a hook to a function
Last modified: August 19, 2016

---

# Adding a hook to a function

 *  [grinfax](https://wordpress.org/support/users/grinfax/)
 * (@grinfax)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/adding-a-hook-to-a-function/)
 * OK, I need to edit the code that is inserted by the get_image_tag function in
   the wp-includes/media.php file. I am adding this to the functions.php file in
   my theme but it’s not working. I could use a little direction here.
 *     ```
       function myget_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 = 'testkim<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title).'" '.$hwstring.'class="'.$class.'" rel="lightbox"/>';
   
       	$html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );
   
       	return $html;
       }
   
       add_action ( 'get_image_tag', 'myget_image_tag($id, $alt, $title, $align, $size="medium")' );
       ```
   

The topic ‘Adding a hook to a function’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [grinfax](https://wordpress.org/support/users/grinfax/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/adding-a-hook-to-a-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
