{"action":"created","comment":{"url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/comments/39625695","id":39625695,"diff_hunk":"@@ -57,7 +57,23 @@ $( document ).on( 'click', '.fm-media-button', function( event ) {\n \t\t$wrapper.html( preview ).trigger( 'fieldmanager_media_preview', [ $wrapper, attachment, wp ] );\n \t});\n \n+\t// Select the attachment when the frame opens\n+\tfm_media_frame[ $el.attr('id') ].on( 'open', function() {\n+\t\t// Select the current attachment inside the frame\n+\t\tvar selection = fm_media_frame[ $el.attr('id') ].state().get('selection'),\n+\t\t\tid = $el.parent().find('.fm-media-id').val(),","path":"js/media/fieldmanager-media.js","position":8,"original_position":8,"commit_id":"b4f816ea3871b5d68350b6e0980132410fef3873","original_commit_id":"b4f816ea3871b5d68350b6e0980132410fef3873","user":{"login":"srtfisher","id":346399,"avatar_url":"https://avatars.githubusercontent.com/u/346399?v=3","gravatar_id":"","url":"https://api.github.com/users/srtfisher","html_url":"https://github.com/srtfisher","followers_url":"https://api.github.com/users/srtfisher/followers","following_url":"https://api.github.com/users/srtfisher/following{/other_user}","gists_url":"https://api.github.com/users/srtfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/srtfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srtfisher/subscriptions","organizations_url":"https://api.github.com/users/srtfisher/orgs","repos_url":"https://api.github.com/users/srtfisher/repos","events_url":"https://api.github.com/users/srtfisher/events{/privacy}","received_events_url":"https://api.github.com/users/srtfisher/received_events","type":"User","site_admin":false},"body":"`$el` is a reference to that specific element's button (be that the media select button or the specific media select button for that attachment in a group. The parent would be `.fm-item`, either the nested `.fm-item` for the item in the group OR the general `.fm-item` for that field. Since we know that, we are able to properly scope the `.fm-media-id` hidden input.\r\n\r\nWe're also using [similar logic](https://github.com/alleyinteractive/wordpress-fieldmanager/blob/master/js/media/fieldmanager-media.js#L46) on the 'select' callback.","created_at":"2015-09-16T12:58:52Z","updated_at":"2015-09-16T12:58:52Z","html_url":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379#discussion_r39625695","pull_request_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379","_links":{"self":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/comments/39625695"},"html":{"href":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379#discussion_r39625695"},"pull_request":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379"}}},"pull_request":{"url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379","id":44959160,"html_url":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379","diff_url":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379.diff","patch_url":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379.patch","issue_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/379","number":379,"state":"open","locked":false,"title":"Selecting media attachment when opening frame","user":{"login":"srtfisher","id":346399,"avatar_url":"https://avatars.githubusercontent.com/u/346399?v=3","gravatar_id":"","url":"https://api.github.com/users/srtfisher","html_url":"https://github.com/srtfisher","followers_url":"https://api.github.com/users/srtfisher/followers","following_url":"https://api.github.com/users/srtfisher/following{/other_user}","gists_url":"https://api.github.com/users/srtfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/srtfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srtfisher/subscriptions","organizations_url":"https://api.github.com/users/srtfisher/orgs","repos_url":"https://api.github.com/users/srtfisher/repos","events_url":"https://api.github.com/users/srtfisher/events{/privacy}","received_events_url":"https://api.github.com/users/srtfisher/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-14T17:45:47Z","updated_at":"2015-09-16T12:58:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed9c7292078babe4f49ea51460354ac0ae2b4911","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379/commits","review_comments_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379/comments","review_comment_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/379/comments","statuses_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/statuses/b4f816ea3871b5d68350b6e0980132410fef3873","head":{"label":"alleyinteractive:select-attachment","ref":"select-attachment","sha":"b4f816ea3871b5d68350b6e0980132410fef3873","user":{"login":"alleyinteractive","id":1733454,"avatar_url":"https://avatars.githubusercontent.com/u/1733454?v=3","gravatar_id":"","url":"https://api.github.com/users/alleyinteractive","html_url":"https://github.com/alleyinteractive","followers_url":"https://api.github.com/users/alleyinteractive/followers","following_url":"https://api.github.com/users/alleyinteractive/following{/other_user}","gists_url":"https://api.github.com/users/alleyinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/alleyinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alleyinteractive/subscriptions","organizations_url":"https://api.github.com/users/alleyinteractive/orgs","repos_url":"https://api.github.com/users/alleyinteractive/repos","events_url":"https://api.github.com/users/alleyinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/alleyinteractive/received_events","type":"Organization","site_admin":false},"repo":{"id":6389464,"name":"wordpress-fieldmanager","full_name":"alleyinteractive/wordpress-fieldmanager","owner":{"login":"alleyinteractive","id":1733454,"avatar_url":"https://avatars.githubusercontent.com/u/1733454?v=3","gravatar_id":"","url":"https://api.github.com/users/alleyinteractive","html_url":"https://github.com/alleyinteractive","followers_url":"https://api.github.com/users/alleyinteractive/followers","following_url":"https://api.github.com/users/alleyinteractive/following{/other_user}","gists_url":"https://api.github.com/users/alleyinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/alleyinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alleyinteractive/subscriptions","organizations_url":"https://api.github.com/users/alleyinteractive/orgs","repos_url":"https://api.github.com/users/alleyinteractive/repos","events_url":"https://api.github.com/users/alleyinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/alleyinteractive/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alleyinteractive/wordpress-fieldmanager","description":"Custom field types for WordPress","fork":false,"url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager","forks_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/forks","keys_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/teams","hooks_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/hooks","issue_events_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/events{/number}","events_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/events","assignees_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/assignees{/user}","branches_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/branches{/branch}","tags_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/tags","blobs_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/refs{/sha}","trees_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/statuses/{sha}","languages_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/languages","stargazers_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/stargazers","contributors_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/contributors","subscribers_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/subscribers","subscription_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/subscription","commits_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/commits{/sha}","git_commits_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/commits{/sha}","comments_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/comments{/number}","issue_comment_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/comments{/number}","contents_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/contents/{+path}","compare_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/merges","archive_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/downloads","issues_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues{/number}","pulls_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls{/number}","milestones_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/milestones{/number}","notifications_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/labels{/name}","releases_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/releases{/id}","created_at":"2012-10-25T15:23:49Z","updated_at":"2015-09-13T21:54:03Z","pushed_at":"2015-09-15T14:17:32Z","git_url":"git://github.com/alleyinteractive/wordpress-fieldmanager.git","ssh_url":"git@github.com:alleyinteractive/wordpress-fieldmanager.git","clone_url":"https://github.com/alleyinteractive/wordpress-fieldmanager.git","svn_url":"https://github.com/alleyinteractive/wordpress-fieldmanager","homepage":null,"size":6498,"stargazers_count":140,"watchers_count":140,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":113,"forks":40,"open_issues":113,"watchers":140,"default_branch":"master"}},"base":{"label":"alleyinteractive:master","ref":"master","sha":"bf8ddd29ea15d28055b60aafcc5b056c3198ef94","user":{"login":"alleyinteractive","id":1733454,"avatar_url":"https://avatars.githubusercontent.com/u/1733454?v=3","gravatar_id":"","url":"https://api.github.com/users/alleyinteractive","html_url":"https://github.com/alleyinteractive","followers_url":"https://api.github.com/users/alleyinteractive/followers","following_url":"https://api.github.com/users/alleyinteractive/following{/other_user}","gists_url":"https://api.github.com/users/alleyinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/alleyinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alleyinteractive/subscriptions","organizations_url":"https://api.github.com/users/alleyinteractive/orgs","repos_url":"https://api.github.com/users/alleyinteractive/repos","events_url":"https://api.github.com/users/alleyinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/alleyinteractive/received_events","type":"Organization","site_admin":false},"repo":{"id":6389464,"name":"wordpress-fieldmanager","full_name":"alleyinteractive/wordpress-fieldmanager","owner":{"login":"alleyinteractive","id":1733454,"avatar_url":"https://avatars.githubusercontent.com/u/1733454?v=3","gravatar_id":"","url":"https://api.github.com/users/alleyinteractive","html_url":"https://github.com/alleyinteractive","followers_url":"https://api.github.com/users/alleyinteractive/followers","following_url":"https://api.github.com/users/alleyinteractive/following{/other_user}","gists_url":"https://api.github.com/users/alleyinteractive/gists{/gist_id}","starred_url":"https://api.github.com/users/alleyinteractive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alleyinteractive/subscriptions","organizations_url":"https://api.github.com/users/alleyinteractive/orgs","repos_url":"https://api.github.com/users/alleyinteractive/repos","events_url":"https://api.github.com/users/alleyinteractive/events{/privacy}","received_events_url":"https://api.github.com/users/alleyinteractive/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alleyinteractive/wordpress-fieldmanager","description":"Custom field types for WordPress","fork":false,"url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager","forks_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/forks","keys_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/teams","hooks_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/hooks","issue_events_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/events{/number}","events_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/events","assignees_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/assignees{/user}","branches_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/branches{/branch}","tags_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/tags","blobs_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/refs{/sha}","trees_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/statuses/{sha}","languages_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/languages","stargazers_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/stargazers","contributors_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/contributors","subscribers_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/subscribers","subscription_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/subscription","commits_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/commits{/sha}","git_commits_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/git/commits{/sha}","comments_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/comments{/number}","issue_comment_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/comments{/number}","contents_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/contents/{+path}","compare_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/merges","archive_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/downloads","issues_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues{/number}","pulls_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls{/number}","milestones_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/milestones{/number}","notifications_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/labels{/name}","releases_url":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/releases{/id}","created_at":"2012-10-25T15:23:49Z","updated_at":"2015-09-13T21:54:03Z","pushed_at":"2015-09-15T14:17:32Z","git_url":"git://github.com/alleyinteractive/wordpress-fieldmanager.git","ssh_url":"git@github.com:alleyinteractive/wordpress-fieldmanager.git","clone_url":"https://github.com/alleyinteractive/wordpress-fieldmanager.git","svn_url":"https://github.com/alleyinteractive/wordpress-fieldmanager","homepage":null,"size":6498,"stargazers_count":140,"watchers_count":140,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":113,"forks":40,"open_issues":113,"watchers":140,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379"},"html":{"href":"https://github.com/alleyinteractive/wordpress-fieldmanager/pull/379"},"issue":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/379"},"comments":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/issues/379/comments"},"review_comments":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379/comments"},"review_comment":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/pulls/379/commits"},"statuses":{"href":"https://api.github.com/repos/alleyinteractive/wordpress-fieldmanager/statuses/b4f816ea3871b5d68350b6e0980132410fef3873"}}}}