Fixes function that delete the pictures from the database.