{"action":"created","comment":{"url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/comments/98256257","pull_request_review_id":18895402,"id":98256257,"diff_hunk":"@@ -161,4 +161,48 @@ protected static function localize( $debug ) {\n \t\twp_localize_script( self::$handle, self::$js_variable, apply_filters( 'cmb2_localized_data', $l10n ) );\n \t}\n \n+\t/**\n+\t * Hook our JS media attachment filter\n+\t * @since  2.x.x.x\n+\t */\n+\tpublic static function filter_media() {\n+\t\tadd_filter( 'wp_prepare_attachment_for_js',  array( __CLASS__, 'prepare_image_sizes_for_js' ) , 10, 3 );\n+\t}\n+\n+\t/**\n+\t * Filters attachment data prepared for JavaScript.\n+\t *\n+\t * Adds the url, width, height, and orientation for custom sizes to the JavaScript\n+\t * object returned by the wp.media uploader. Hooked to 'wp_prepare_attachment_for_js'.\n+\t *\n+\t * @since  2.x.x.x\n+\t * @param  array      $response   Array of prepared attachment data.\n+\t * @param  int|object $attachment Attachment ID or object.\n+\t * @param  array      $meta       Array of attachment meta data ( from wp_get_attachment_metadata() ).\n+\t * @return string     filtered $response array\n+\t */\n+\tpublic static function prepare_image_sizes_for_js( $response, $attachment, $meta ) {","path":"includes/CMB2_JS.php","position":24,"original_position":24,"commit_id":"84bdca61a14ce0f34279da8e310def74eee4ef1e","original_commit_id":"84bdca61a14ce0f34279da8e310def74eee4ef1e","user":{"login":"Cai333","id":19490066,"avatar_url":"https://avatars.githubusercontent.com/u/19490066?v=3","gravatar_id":"","url":"https://api.github.com/users/Cai333","html_url":"https://github.com/Cai333","followers_url":"https://api.github.com/users/Cai333/followers","following_url":"https://api.github.com/users/Cai333/following{/other_user}","gists_url":"https://api.github.com/users/Cai333/gists{/gist_id}","starred_url":"https://api.github.com/users/Cai333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cai333/subscriptions","organizations_url":"https://api.github.com/users/Cai333/orgs","repos_url":"https://api.github.com/users/Cai333/repos","events_url":"https://api.github.com/users/Cai333/events{/privacy}","received_events_url":"https://api.github.com/users/Cai333/received_events","type":"User","site_admin":false},"body":"Honestly, it was a struggle trying to decide where to hook this in, this sounds better!","created_at":"2017-01-27T18:02:44Z","updated_at":"2017-01-27T18:02:44Z","html_url":"https://github.com/WebDevStudios/CMB2/pull/848#discussion_r98256257","pull_request_url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848","_links":{"self":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/comments/98256257"},"html":{"href":"https://github.com/WebDevStudios/CMB2/pull/848#discussion_r98256257"},"pull_request":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848"}}},"pull_request":{"url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848","id":103526654,"html_url":"https://github.com/WebDevStudios/CMB2/pull/848","diff_url":"https://github.com/WebDevStudios/CMB2/pull/848.diff","patch_url":"https://github.com/WebDevStudios/CMB2/pull/848.patch","issue_url":"https://api.github.com/repos/WebDevStudios/CMB2/issues/848","number":848,"state":"open","locked":false,"title":"Make file/file_list field preview images work with named sizes","user":{"login":"Cai333","id":19490066,"avatar_url":"https://avatars.githubusercontent.com/u/19490066?v=3","gravatar_id":"","url":"https://api.github.com/users/Cai333","html_url":"https://github.com/Cai333","followers_url":"https://api.github.com/users/Cai333/followers","following_url":"https://api.github.com/users/Cai333/following{/other_user}","gists_url":"https://api.github.com/users/Cai333/gists{/gist_id}","starred_url":"https://api.github.com/users/Cai333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cai333/subscriptions","organizations_url":"https://api.github.com/users/Cai333/orgs","repos_url":"https://api.github.com/users/Cai333/repos","events_url":"https://api.github.com/users/Cai333/events{/privacy}","received_events_url":"https://api.github.com/users/Cai333/received_events","type":"User","site_admin":false},"body":"Fixes #844.\r\n\r\n-  Add some utility methods for working with named images.\r\n\r\n-  Filter the attachment meta data passed to the JS media uploader and adds all custom\r\n  (i.e. registered with `add_image_size()`) image sizes.\r\n\r\n-  File and File List fields try to get the closest named image size if passed an array for the `preview_size` parameter. If passed a string, the string is checked against existing image sizes. The named size is then passed as a data attribute to the hidden field to be used by the JS media uploader.\r\n\r\n- The JavaScript that handles the media uploader now checks the named size passed from the hidden field and retrieves the correct image from the attachment object returned by the media uploader. The dimensions are then adjusted to fit within the preview size (rather than being stretched as they were before).\r\n\r\n- Changed the default `preview_size` from 350x350px (for `file` fields) and 50x50px (for `file_list` fields) to the named sizes `large` and `thumbnail` respectively.","created_at":"2017-01-27T16:49:08Z","updated_at":"2017-01-27T18:02:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"601d2fb2a166c62e394614f2a37888fd12e08116","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848/commits","review_comments_url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848/comments","review_comment_url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WebDevStudios/CMB2/issues/848/comments","statuses_url":"https://api.github.com/repos/WebDevStudios/CMB2/statuses/84bdca61a14ce0f34279da8e310def74eee4ef1e","head":{"label":"Cai333:trunk","ref":"trunk","sha":"84bdca61a14ce0f34279da8e310def74eee4ef1e","user":{"login":"Cai333","id":19490066,"avatar_url":"https://avatars.githubusercontent.com/u/19490066?v=3","gravatar_id":"","url":"https://api.github.com/users/Cai333","html_url":"https://github.com/Cai333","followers_url":"https://api.github.com/users/Cai333/followers","following_url":"https://api.github.com/users/Cai333/following{/other_user}","gists_url":"https://api.github.com/users/Cai333/gists{/gist_id}","starred_url":"https://api.github.com/users/Cai333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cai333/subscriptions","organizations_url":"https://api.github.com/users/Cai333/orgs","repos_url":"https://api.github.com/users/Cai333/repos","events_url":"https://api.github.com/users/Cai333/events{/privacy}","received_events_url":"https://api.github.com/users/Cai333/received_events","type":"User","site_admin":false},"repo":{"id":79747048,"name":"CMB2","full_name":"Cai333/CMB2","owner":{"login":"Cai333","id":19490066,"avatar_url":"https://avatars.githubusercontent.com/u/19490066?v=3","gravatar_id":"","url":"https://api.github.com/users/Cai333","html_url":"https://github.com/Cai333","followers_url":"https://api.github.com/users/Cai333/followers","following_url":"https://api.github.com/users/Cai333/following{/other_user}","gists_url":"https://api.github.com/users/Cai333/gists{/gist_id}","starred_url":"https://api.github.com/users/Cai333/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cai333/subscriptions","organizations_url":"https://api.github.com/users/Cai333/orgs","repos_url":"https://api.github.com/users/Cai333/repos","events_url":"https://api.github.com/users/Cai333/events{/privacy}","received_events_url":"https://api.github.com/users/Cai333/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Cai333/CMB2","description":"CMB2 is a developer's toolkit for building metaboxes, custom fields, and forms for WordPress that will blow your mind.","fork":true,"url":"https://api.github.com/repos/Cai333/CMB2","forks_url":"https://api.github.com/repos/Cai333/CMB2/forks","keys_url":"https://api.github.com/repos/Cai333/CMB2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Cai333/CMB2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Cai333/CMB2/teams","hooks_url":"https://api.github.com/repos/Cai333/CMB2/hooks","issue_events_url":"https://api.github.com/repos/Cai333/CMB2/issues/events{/number}","events_url":"https://api.github.com/repos/Cai333/CMB2/events","assignees_url":"https://api.github.com/repos/Cai333/CMB2/assignees{/user}","branches_url":"https://api.github.com/repos/Cai333/CMB2/branches{/branch}","tags_url":"https://api.github.com/repos/Cai333/CMB2/tags","blobs_url":"https://api.github.com/repos/Cai333/CMB2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Cai333/CMB2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Cai333/CMB2/git/refs{/sha}","trees_url":"https://api.github.com/repos/Cai333/CMB2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Cai333/CMB2/statuses/{sha}","languages_url":"https://api.github.com/repos/Cai333/CMB2/languages","stargazers_url":"https://api.github.com/repos/Cai333/CMB2/stargazers","contributors_url":"https://api.github.com/repos/Cai333/CMB2/contributors","subscribers_url":"https://api.github.com/repos/Cai333/CMB2/subscribers","subscription_url":"https://api.github.com/repos/Cai333/CMB2/subscription","commits_url":"https://api.github.com/repos/Cai333/CMB2/commits{/sha}","git_commits_url":"https://api.github.com/repos/Cai333/CMB2/git/commits{/sha}","comments_url":"https://api.github.com/repos/Cai333/CMB2/comments{/number}","issue_comment_url":"https://api.github.com/repos/Cai333/CMB2/issues/comments{/number}","contents_url":"https://api.github.com/repos/Cai333/CMB2/contents/{+path}","compare_url":"https://api.github.com/repos/Cai333/CMB2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Cai333/CMB2/merges","archive_url":"https://api.github.com/repos/Cai333/CMB2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Cai333/CMB2/downloads","issues_url":"https://api.github.com/repos/Cai333/CMB2/issues{/number}","pulls_url":"https://api.github.com/repos/Cai333/CMB2/pulls{/number}","milestones_url":"https://api.github.com/repos/Cai333/CMB2/milestones{/number}","notifications_url":"https://api.github.com/repos/Cai333/CMB2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Cai333/CMB2/labels{/name}","releases_url":"https://api.github.com/repos/Cai333/CMB2/releases{/id}","deployments_url":"https://api.github.com/repos/Cai333/CMB2/deployments","created_at":"2017-01-22T21:29:55Z","updated_at":"2017-01-22T21:29:58Z","pushed_at":"2017-01-27T16:23:53Z","git_url":"git://github.com/Cai333/CMB2.git","ssh_url":"git@github.com:Cai333/CMB2.git","clone_url":"https://github.com/Cai333/CMB2.git","svn_url":"https://github.com/Cai333/CMB2","homepage":"","size":4848,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"WebDevStudios:trunk","ref":"trunk","sha":"6dacea9c1af974bd3ce253b7ff74403c23d74b8e","user":{"login":"WebDevStudios","id":1446784,"avatar_url":"https://avatars.githubusercontent.com/u/1446784?v=3","gravatar_id":"","url":"https://api.github.com/users/WebDevStudios","html_url":"https://github.com/WebDevStudios","followers_url":"https://api.github.com/users/WebDevStudios/followers","following_url":"https://api.github.com/users/WebDevStudios/following{/other_user}","gists_url":"https://api.github.com/users/WebDevStudios/gists{/gist_id}","starred_url":"https://api.github.com/users/WebDevStudios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WebDevStudios/subscriptions","organizations_url":"https://api.github.com/users/WebDevStudios/orgs","repos_url":"https://api.github.com/users/WebDevStudios/repos","events_url":"https://api.github.com/users/WebDevStudios/events{/privacy}","received_events_url":"https://api.github.com/users/WebDevStudios/received_events","type":"Organization","site_admin":false},"repo":{"id":23156260,"name":"CMB2","full_name":"WebDevStudios/CMB2","owner":{"login":"WebDevStudios","id":1446784,"avatar_url":"https://avatars.githubusercontent.com/u/1446784?v=3","gravatar_id":"","url":"https://api.github.com/users/WebDevStudios","html_url":"https://github.com/WebDevStudios","followers_url":"https://api.github.com/users/WebDevStudios/followers","following_url":"https://api.github.com/users/WebDevStudios/following{/other_user}","gists_url":"https://api.github.com/users/WebDevStudios/gists{/gist_id}","starred_url":"https://api.github.com/users/WebDevStudios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WebDevStudios/subscriptions","organizations_url":"https://api.github.com/users/WebDevStudios/orgs","repos_url":"https://api.github.com/users/WebDevStudios/repos","events_url":"https://api.github.com/users/WebDevStudios/events{/privacy}","received_events_url":"https://api.github.com/users/WebDevStudios/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WebDevStudios/CMB2","description":"CMB2 is a developer's toolkit for building metaboxes, custom fields, and forms for WordPress that will blow your mind.","fork":false,"url":"https://api.github.com/repos/WebDevStudios/CMB2","forks_url":"https://api.github.com/repos/WebDevStudios/CMB2/forks","keys_url":"https://api.github.com/repos/WebDevStudios/CMB2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WebDevStudios/CMB2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WebDevStudios/CMB2/teams","hooks_url":"https://api.github.com/repos/WebDevStudios/CMB2/hooks","issue_events_url":"https://api.github.com/repos/WebDevStudios/CMB2/issues/events{/number}","events_url":"https://api.github.com/repos/WebDevStudios/CMB2/events","assignees_url":"https://api.github.com/repos/WebDevStudios/CMB2/assignees{/user}","branches_url":"https://api.github.com/repos/WebDevStudios/CMB2/branches{/branch}","tags_url":"https://api.github.com/repos/WebDevStudios/CMB2/tags","blobs_url":"https://api.github.com/repos/WebDevStudios/CMB2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WebDevStudios/CMB2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WebDevStudios/CMB2/git/refs{/sha}","trees_url":"https://api.github.com/repos/WebDevStudios/CMB2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WebDevStudios/CMB2/statuses/{sha}","languages_url":"https://api.github.com/repos/WebDevStudios/CMB2/languages","stargazers_url":"https://api.github.com/repos/WebDevStudios/CMB2/stargazers","contributors_url":"https://api.github.com/repos/WebDevStudios/CMB2/contributors","subscribers_url":"https://api.github.com/repos/WebDevStudios/CMB2/subscribers","subscription_url":"https://api.github.com/repos/WebDevStudios/CMB2/subscription","commits_url":"https://api.github.com/repos/WebDevStudios/CMB2/commits{/sha}","git_commits_url":"https://api.github.com/repos/WebDevStudios/CMB2/git/commits{/sha}","comments_url":"https://api.github.com/repos/WebDevStudios/CMB2/comments{/number}","issue_comment_url":"https://api.github.com/repos/WebDevStudios/CMB2/issues/comments{/number}","contents_url":"https://api.github.com/repos/WebDevStudios/CMB2/contents/{+path}","compare_url":"https://api.github.com/repos/WebDevStudios/CMB2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WebDevStudios/CMB2/merges","archive_url":"https://api.github.com/repos/WebDevStudios/CMB2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WebDevStudios/CMB2/downloads","issues_url":"https://api.github.com/repos/WebDevStudios/CMB2/issues{/number}","pulls_url":"https://api.github.com/repos/WebDevStudios/CMB2/pulls{/number}","milestones_url":"https://api.github.com/repos/WebDevStudios/CMB2/milestones{/number}","notifications_url":"https://api.github.com/repos/WebDevStudios/CMB2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WebDevStudios/CMB2/labels{/name}","releases_url":"https://api.github.com/repos/WebDevStudios/CMB2/releases{/id}","deployments_url":"https://api.github.com/repos/WebDevStudios/CMB2/deployments","created_at":"2014-08-20T16:49:33Z","updated_at":"2017-01-26T18:32:24Z","pushed_at":"2017-01-27T16:49:09Z","git_url":"git://github.com/WebDevStudios/CMB2.git","ssh_url":"git@github.com:WebDevStudios/CMB2.git","clone_url":"https://github.com/WebDevStudios/CMB2.git","svn_url":"https://github.com/WebDevStudios/CMB2","homepage":"","size":4851,"stargazers_count":1492,"watchers_count":1492,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":360,"mirror_url":null,"open_issues_count":177,"forks":360,"open_issues":177,"watchers":1492,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848"},"html":{"href":"https://github.com/WebDevStudios/CMB2/pull/848"},"issue":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/issues/848"},"comments":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/issues/848/comments"},"review_comments":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848/comments"},"review_comment":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/pulls/848/commits"},"statuses":{"href":"https://api.github.com/repos/WebDevStudios/CMB2/statuses/84bdca61a14ce0f34279da8e310def74eee4ef1e"}}}}
{"actor":{"display_login":"Cai333"}}