{"action":"created","issue":{"url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/36","labels_url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/36/comments","events_url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/36/events","html_url":"https://github.com/syamilmj/Aqua-Resizer/issues/36","id":18277211,"number":36,"title":"Retina Support - Generating an @2x image for retina.js","user":{"login":"wpexplorer","id":1128841,"avatar_url":"https://avatars.githubusercontent.com/u/1128841?v=3","gravatar_id":"","url":"https://api.github.com/users/wpexplorer","html_url":"https://github.com/wpexplorer","followers_url":"https://api.github.com/users/wpexplorer/followers","following_url":"https://api.github.com/users/wpexplorer/following{/other_user}","gists_url":"https://api.github.com/users/wpexplorer/gists{/gist_id}","starred_url":"https://api.github.com/users/wpexplorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpexplorer/subscriptions","organizations_url":"https://api.github.com/users/wpexplorer/orgs","repos_url":"https://api.github.com/users/wpexplorer/repos","events_url":"https://api.github.com/users/wpexplorer/events{/privacy}","received_events_url":"https://api.github.com/users/wpexplorer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2013-08-20T04:21:27Z","updated_at":"2015-03-17T12:35:06Z","closed_at":null,"body":"Here is the code I came up with and it seems to work pretty good, thought I'd share it with everyone (just add it before return $image; )\r\n\r\n<pre>\r\n// RETINA Support --------------------------------------------------------------->\t\r\n\t\t\t$retina_w = $dst_w*2;\r\n\t\t\t$retina_h = $dst_h*2;\r\n\t\t\t\r\n\t\t\t//get image size after cropping\r\n\t\t\t$dims_x2 = image_resize_dimensions($orig_w, $orig_h, $retina_w, $retina_h, $crop);\r\n\t\t\t$dst_x2_w = $dims_x2[4];\r\n\t\t\t$dst_x2_h = $dims_x2[5];\r\n\t\t\t\r\n\t\t\t// If possible lets make the @2x image\r\n\t\t\tif($dst_x2_h) {\r\n\t\t\t\r\n\t\t\t\t//@2x image url\r\n\t\t\t\t$destfilename = \"{$upload_dir}{$dst_rel_path}-{$suffix}@2x.{$ext}\";\r\n\t\t\t\t\r\n\t\t\t\t//check if retina image exists\r\n\t\t\t\tif(file_exists($destfilename) && getimagesize($destfilename)) {\t\r\n\t\t\t\t\t// already exists, do nothing\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// doesnt exist, lets create it\r\n\t\t\t\t\t$editor = wp_get_image_editor($img_path);\r\n\t\t\t\t\tif ( ! is_wp_error( $editor ) ) {\r\n\t\t\t\t\t\t$editor->resize( $retina_w, $retina_h, $crop );\r\n\t\t\t\t\t\t$editor->set_quality( 100 );\r\n\t\t\t\t\t\t$filename = $editor->generate_filename( $dst_w . 'x' . $dst_h . '@2x'  );\r\n\t\t\t\t\t\t$editor = $editor->save($filename);\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\r\n\t\t\t}\r\n</pre>\r\n\r\nThen just include retina.js with your theme and you are good to go - http://retinajs.com/"},"comment":{"url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/comments/82322470","html_url":"https://github.com/syamilmj/Aqua-Resizer/issues/36#issuecomment-82322470","issue_url":"https://api.github.com/repos/syamilmj/Aqua-Resizer/issues/36","id":82322470,"user":{"login":"goranefbl","id":1670309,"avatar_url":"https://avatars.githubusercontent.com/u/1670309?v=3","gravatar_id":"","url":"https://api.github.com/users/goranefbl","html_url":"https://github.com/goranefbl","followers_url":"https://api.github.com/users/goranefbl/followers","following_url":"https://api.github.com/users/goranefbl/following{/other_user}","gists_url":"https://api.github.com/users/goranefbl/gists{/gist_id}","starred_url":"https://api.github.com/users/goranefbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goranefbl/subscriptions","organizations_url":"https://api.github.com/users/goranefbl/orgs","repos_url":"https://api.github.com/users/goranefbl/repos","events_url":"https://api.github.com/users/goranefbl/events{/privacy}","received_events_url":"https://api.github.com/users/goranefbl/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T12:35:06Z","updated_at":"2015-03-17T12:35:06Z","body":"Added similar, you can check on https://github.com/goranefbl/Aqua-Resizer ,tested and works just fine, you just ned retina.js script."}}