Sorry for the delay in answering.
The problem described in my original post occur on my Macbook Pro. On my Mac Mini the same folders have a different behaviour. On the Mini only 1 photo show up in each of two folders where I have lost the most photos. No shaded rectangles appear. But they do appear in other folders, but in lesser numbers.
On the Mini, when i tap on a photo, a blank page opens and if I try to edit it I get the message saying "An error occurred while fetching a larger version of the photo for editing. Try again later" (translated from Danish :-) )
On the Macbook Pro, when I tap on a photo, only a blank page opens and nothing happens if I try to edit.
This is happening with photos that show as a shaded rectangle with a iCloud logo. On the Macbook Pro photos still show up as shaded rectangles with exclamation point warning triangles in the middle. However, there is a shaded rectangle for each photo that is supposed to be there. And when I bring up the folder on the Macbook Pro all photos briefly show in low res, only to be replaced by the warnings.
On the Macbook Pro there are some photos that show up with the iCloud logo instead off the warning triangle.