I wanted to execute a shortcode via echo do_shortcode('[justified-image-grid ids="nnnn"]') , combined with a $variable for the ‘nnnn’ part. This didn’t work. A static shortcode like echo do_shortcode('[justified-image-grid ids=featured]') worked for me, but setting the featured image manually. That (version a worked fine, version b didn’t work) was the reason to ask you and not any community like stackexchange.
Now I found a solution. I could make the image in the attachment page to the featured image of that page (with set_post_thumbnail()). After that I could use a static shortcode [justified-image-grid ids=featured] as mentioned before.
Thanks for your help