WP query retrieve the src of attached image

You can use wp_get_attachment_image_src and get your desired sized image and then pass onto your array :

foreach( $posts as $post ) {
    $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "medium" );
    $imgsrc = $imgsrc[0];

    $output[] = array(

    'id' => $post->ID, 
    'title' => $post->post_title, 
    'count' => $post->custom_total_hits, 
    'soundcloud_url' => $post->soundcloud_song, 
    'soundcloud_id' => $post->soundcloud_ids, 
    'link' => get_permalink($post), 
    'image_src' => $imgsrc
    );
 }     

echo json_encode($output);  

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