Looks like you’ve got two issues:
The first is your use of $q->ID. This is not the correct way to get the current post id from inside a loop. You want to use get_the_ID().
The second issue is you should be using get_bloginfo() instead of bloginfo(). Bloginfo echo’s the data directly while get_bloginfo() returns it (allowing you to assign to the $location variable).
One last suggestion: get_bloginfo(‘template_directory’) is not going to be changing values in each iteration of your loop. You can move that line outside of the loop to save some resources.