Grid With Images - Adding Images to a column and displaying them (Many to Many Relationship)

I want to be able to upload images to a grid and show them for the users to view the images. 

The problem is its not

1) 1 to 1 relationship ( i.e one row will have only image)

2) 1 to many relationship ( i.e one row will have many images)

Its many to many - many rows together can be associated with many images, many rows together can be associated with 1 image, 1 row can be associated with 1 image or 1 row can associated with many images.

Basically looking for Something like an excel sheet where i can merge the cells and show them as common for certain rows. Attached image for reference.

 

I am looking for suggestions as to the best UX for this feature.

Uploading:

What is the best way to build this to ensure users can select multiple rows and upload associated images for those selections, ability to remove a row with an association, ability to reassign a row from one associated image to another in case i have assigned it wrongly.

 

Viewing:

See the associated images directly on the grid instead of clicking a link and showing the images as links. In the paging grid, i can show only 1 image per row and not more than that. I also cannot associate multiple rows with same set of image.

 

 

 

  Discussion posts and replies are publicly visible