I had the same issue with the [gallery] code. Here is how I fixed the problem.
Open the gallery dialog. You can see ‘Link thumbnails to’ under Gallery Settings. Make sure to select “link to image file”. That’s all and this should solve your problem.