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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)