If there are specific images that are relevant only for certain dynamic items you can use a WixDataQuery in order to retrieve those specific images and populate the gallery element via code.
If not, connecting by dataset is the easiest way.
It all depends on the case.
You can also share a link to your site (please specify page name) and I’ll take a look at it so I can give you the best solution for your case.
Doron.