The first thing you would need to get worked out is the page that dynamically creates the gallery. Do you have a page like this already? This is really the key to this. You would need to have this page successfully creating the gallery for you first. Once you can do that then you can easily add in a button that will take you to this page with the records id, it can just be a link or a form with a submit button. When you insert the new gallery you can just reference your id value that was passed over the URL or posted to the page.
Once the page is crafted and creating a new gallery then you can add in the contact portion to the form.