wp_get_attachment_link to add title attribute to link tag around image

I found a solution. Since the wp_get_attachment_link does not seem to work I solved this within an already used other filter:img_caption_shortcode

Within this filter function the content variable contains the image link tag. Here a just added the title using a simple search and replace:

$content = str_replace("<a","<a title="".$attr["caption'] . $credit."'", $content);

This way it works perfectly.

error code: 523