Adding a querystring to an image URL when clicking 'insert into post'?

I have written a plugin which does some fancy stuff with GD lib when you upload an image.

Everything is working fine, however I need to get the image title and add it to the image URL (and file name of the image) when the user clicks ‘insert into post’, but can’t find any references which could help me.

Solutions Collecting From Web of "Adding a querystring to an image URL when clicking 'insert into post'?"

You need to use the filter image_send_to_editor.

add_filter('image_send_to_editor', 'wpse_62869_img_wrapper', 20, 8);

function wpse_62869_img_wrapper( $html, $id, $caption, $title, $align, $url, $size, $alt ) 
{
    return $html;
}

These are the values of a test insert and you can use them to build your own $html response.

html     |  <a href="http://wp34.dev/wp-content/uploads/2012/11/escritorio.jpg"><img src="http://wp34.dev/wp-content/uploads/2012/11/escritorio-224x300.jpg" alt="Alt text for the image" title="escritorio" width="224" height="300" class="aligncenter size-medium wp-image-9" /></a>
id       |  9
caption  |  The image caption
title    |  escritorio
align    |  center
url      |  http://wp34.dev/wp-content/uploads/2012/11/escritorio.jpg
size     |  medium
alt      |  Alt text for the image