You could add a separate column to the database for each entry and have it store whether or not the image is suitable for the random display. Then in the query for the random image, you would want to add in a condition so that the value of that column is suitable.
For example, if you added the column, randomDisplay and had it be a boolean, in your query, you would want to check that randomDisplay = true. You would want to set randomDisplay to false if the entry is not suitable for display.