Allow only attachment uploaded to current post

Maybe I was over thinking, but the solution is easier than I thought.

I just have to limit the event handler to some element, so other unrelated ones will not trigger the handler. In this case, .media-modal is the overall parent of the media library element, so I am specifying this extra selector to the event, like below:

jQuery(document).on("DOMNodeInserted", '.media-modal', function() {
    // ...
}

And after testing, this will speed up the other insertion of nodes.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)