{"action":"created","comment":{"url":"https://api.github.com/repos/rstudio/blogdown/pulls/comments/172634400","pull_request_review_id":101685494,"id":172634400,"diff_hunk":"@@ -0,0 +1,59 @@\n+local({\n+  txt_input = function(..., width = '100%') shiny::textInput(..., width = width)\n+\n+  blogfile = rstudioapi::getActiveDocumentContext()\n+  if(blogfile$path == '') stop('Please select the blog post source file before using this addin', call. = FALSE)\n+\n+  imgdir = file.path(\n+    gsub('/content/.*', '', normalizePath(blogfile$path)),\n+    'static',\n+    dirname(gsub('.*content/', '', normalizePath(blogfile$path))),\n+    paste0(xfun::sans_ext(basename(blogfile$path)), '_files')\n+  )\n+\n+  shiny::runGadget(\n+    miniUI::miniPage(miniUI::miniContentPanel(\n+      shiny::fillRow(\n+        shiny::fileInput('newimg', 'Image', placeholder = 'Select external image'),\n+        height = '90px'\n+      ),\n+      shiny::fillRow(\n+        txt_input('imgwidth', 'Image width', '', '(optional) Example: 400 for 400px'),\n+        txt_input('imgheight', 'Image height', '', '(optional) Example: 200 for 200px'),\n+        height = '70px'),\n+      shiny::fillRow(\n+        txt_input('imgalt', 'Image alternative text', '', '(optional) Example: awesome screenshot'),\n+        height = '70px'\n+      ),\n+      miniUI::gadgetTitleBar(NULL)\n+    )),\n+    server = function(input, output, session) {\n+      shiny::observeEvent(input$done, {\n+        if (is.null(input$newimg)) return(\n+          warning('You have to choose an image!', call. = FALSE)\n+        )\n+        dir.create(imgdir, showWarnings = FALSE)\n+        file.copy(input$newimg$datapath, file.path(imgdir, input$newimg$name))\n+        if(file.exists(file.path(imgdir, input$newimg$name))) message(paste('successfully copied the image to', file.path(imgdir, input$newimg$name)))\n+        \n+        imgsrc = paste0(\n+          \"/\",\n+          basename(dirname(imgdir)),\n+          \"/\",\n+          basename(imgdir),\n+          \"/\",\n+          input$newimg$name\n+        )\n+                \n+        image_text = if(input$imgwidth == '' & input$imgheight == '') shiny::img(src = imgsrc) else if (input$imgwidth == '') shiny::img(src = imgsrc, height = input$imgheight) else if(input$imgheight == '') shiny::img(src = imgsrc, width = input$imgwidth) else shiny::img(src = imgsrc, width = input$imgwidth, height = input$imgheight)","path":"inst/scripts/insert_image.R","position":null,"original_position":48,"commit_id":"7fe6e950f7d3ffc093c6b8ae6d3787eb933eeb88","original_commit_id":"4a88ce0b43d83ae9d8b45bf203078100e252566b","user":{"login":"lcolladotor","id":2288213,"avatar_url":"https://avatars2.githubusercontent.com/u/2288213?v=4","gravatar_id":"","url":"https://api.github.com/users/lcolladotor","html_url":"https://github.com/lcolladotor","followers_url":"https://api.github.com/users/lcolladotor/followers","following_url":"https://api.github.com/users/lcolladotor/following{/other_user}","gists_url":"https://api.github.com/users/lcolladotor/gists{/gist_id}","starred_url":"https://api.github.com/users/lcolladotor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcolladotor/subscriptions","organizations_url":"https://api.github.com/users/lcolladotor/orgs","repos_url":"https://api.github.com/users/lcolladotor/repos","events_url":"https://api.github.com/users/lcolladotor/events{/privacy}","received_events_url":"https://api.github.com/users/lcolladotor/received_events","type":"User","site_admin":false},"body":"I made markdown the default when no height/width are specified.\r\n\r\nAs for resizing the image. Well, I normally preview the website and adjust image heights/widths as necessary afterwards. Resizing the image makes sense for non-html outputs (aka, when using the markdown syntax). ","created_at":"2018-03-06T19:35:00Z","updated_at":"2018-03-06T19:35:00Z","html_url":"https://github.com/rstudio/blogdown/pull/272#discussion_r172634400","pull_request_url":"https://api.github.com/repos/rstudio/blogdown/pulls/272","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/comments/172634400"},"html":{"href":"https://github.com/rstudio/blogdown/pull/272#discussion_r172634400"},"pull_request":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/272"}},"in_reply_to_id":172602648},"pull_request":{"url":"https://api.github.com/repos/rstudio/blogdown/pulls/272","id":173221206,"html_url":"https://github.com/rstudio/blogdown/pull/272","diff_url":"https://github.com/rstudio/blogdown/pull/272.diff","patch_url":"https://github.com/rstudio/blogdown/pull/272.patch","issue_url":"https://api.github.com/repos/rstudio/blogdown/issues/272","number":272,"state":"open","locked":false,"title":"v0.5.7 -- adds insert external image addin. Resolves #269","user":{"login":"lcolladotor","id":2288213,"avatar_url":"https://avatars2.githubusercontent.com/u/2288213?v=4","gravatar_id":"","url":"https://api.github.com/users/lcolladotor","html_url":"https://github.com/lcolladotor","followers_url":"https://api.github.com/users/lcolladotor/followers","following_url":"https://api.github.com/users/lcolladotor/following{/other_user}","gists_url":"https://api.github.com/users/lcolladotor/gists{/gist_id}","starred_url":"https://api.github.com/users/lcolladotor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcolladotor/subscriptions","organizations_url":"https://api.github.com/users/lcolladotor/orgs","repos_url":"https://api.github.com/users/lcolladotor/repos","events_url":"https://api.github.com/users/lcolladotor/events{/privacy}","received_events_url":"https://api.github.com/users/lcolladotor/received_events","type":"User","site_admin":false},"body":"This PR adds an external image RStudio addin. Tested as described at https://github.com/rstudio/blogdown/issues/269.\r\n\r\nI'm not sure that what I did for defining `image_text` is the best given all the if else. But I would like the addin to have the flexibility of specifying width/height since I myself would probably use this very frequently.\r\n","created_at":"2018-03-06T17:03:47Z","updated_at":"2018-03-06T19:35:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e8e0d3167cc03036169f6e69b2a8e0499274db2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rstudio/blogdown/pulls/272/commits","review_comments_url":"https://api.github.com/repos/rstudio/blogdown/pulls/272/comments","review_comment_url":"https://api.github.com/repos/rstudio/blogdown/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rstudio/blogdown/issues/272/comments","statuses_url":"https://api.github.com/repos/rstudio/blogdown/statuses/7fe6e950f7d3ffc093c6b8ae6d3787eb933eeb88","head":{"label":"lcolladotor:insert_image_addin","ref":"insert_image_addin","sha":"7fe6e950f7d3ffc093c6b8ae6d3787eb933eeb88","user":{"login":"lcolladotor","id":2288213,"avatar_url":"https://avatars2.githubusercontent.com/u/2288213?v=4","gravatar_id":"","url":"https://api.github.com/users/lcolladotor","html_url":"https://github.com/lcolladotor","followers_url":"https://api.github.com/users/lcolladotor/followers","following_url":"https://api.github.com/users/lcolladotor/following{/other_user}","gists_url":"https://api.github.com/users/lcolladotor/gists{/gist_id}","starred_url":"https://api.github.com/users/lcolladotor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcolladotor/subscriptions","organizations_url":"https://api.github.com/users/lcolladotor/orgs","repos_url":"https://api.github.com/users/lcolladotor/repos","events_url":"https://api.github.com/users/lcolladotor/events{/privacy}","received_events_url":"https://api.github.com/users/lcolladotor/received_events","type":"User","site_admin":false},"repo":{"id":124109346,"name":"blogdown","full_name":"lcolladotor/blogdown","owner":{"login":"lcolladotor","id":2288213,"avatar_url":"https://avatars2.githubusercontent.com/u/2288213?v=4","gravatar_id":"","url":"https://api.github.com/users/lcolladotor","html_url":"https://github.com/lcolladotor","followers_url":"https://api.github.com/users/lcolladotor/followers","following_url":"https://api.github.com/users/lcolladotor/following{/other_user}","gists_url":"https://api.github.com/users/lcolladotor/gists{/gist_id}","starred_url":"https://api.github.com/users/lcolladotor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcolladotor/subscriptions","organizations_url":"https://api.github.com/users/lcolladotor/orgs","repos_url":"https://api.github.com/users/lcolladotor/repos","events_url":"https://api.github.com/users/lcolladotor/events{/privacy}","received_events_url":"https://api.github.com/users/lcolladotor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lcolladotor/blogdown","description":"Create Blogs and Websites with R Markdown","fork":true,"url":"https://api.github.com/repos/lcolladotor/blogdown","forks_url":"https://api.github.com/repos/lcolladotor/blogdown/forks","keys_url":"https://api.github.com/repos/lcolladotor/blogdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lcolladotor/blogdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lcolladotor/blogdown/teams","hooks_url":"https://api.github.com/repos/lcolladotor/blogdown/hooks","issue_events_url":"https://api.github.com/repos/lcolladotor/blogdown/issues/events{/number}","events_url":"https://api.github.com/repos/lcolladotor/blogdown/events","assignees_url":"https://api.github.com/repos/lcolladotor/blogdown/assignees{/user}","branches_url":"https://api.github.com/repos/lcolladotor/blogdown/branches{/branch}","tags_url":"https://api.github.com/repos/lcolladotor/blogdown/tags","blobs_url":"https://api.github.com/repos/lcolladotor/blogdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lcolladotor/blogdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lcolladotor/blogdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/lcolladotor/blogdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lcolladotor/blogdown/statuses/{sha}","languages_url":"https://api.github.com/repos/lcolladotor/blogdown/languages","stargazers_url":"https://api.github.com/repos/lcolladotor/blogdown/stargazers","contributors_url":"https://api.github.com/repos/lcolladotor/blogdown/contributors","subscribers_url":"https://api.github.com/repos/lcolladotor/blogdown/subscribers","subscription_url":"https://api.github.com/repos/lcolladotor/blogdown/subscription","commits_url":"https://api.github.com/repos/lcolladotor/blogdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/lcolladotor/blogdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/lcolladotor/blogdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/lcolladotor/blogdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/lcolladotor/blogdown/contents/{+path}","compare_url":"https://api.github.com/repos/lcolladotor/blogdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lcolladotor/blogdown/merges","archive_url":"https://api.github.com/repos/lcolladotor/blogdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lcolladotor/blogdown/downloads","issues_url":"https://api.github.com/repos/lcolladotor/blogdown/issues{/number}","pulls_url":"https://api.github.com/repos/lcolladotor/blogdown/pulls{/number}","milestones_url":"https://api.github.com/repos/lcolladotor/blogdown/milestones{/number}","notifications_url":"https://api.github.com/repos/lcolladotor/blogdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lcolladotor/blogdown/labels{/name}","releases_url":"https://api.github.com/repos/lcolladotor/blogdown/releases{/id}","deployments_url":"https://api.github.com/repos/lcolladotor/blogdown/deployments","created_at":"2018-03-06T16:52:13Z","updated_at":"2018-03-06T16:52:15Z","pushed_at":"2018-03-06T19:30:51Z","git_url":"git://github.com/lcolladotor/blogdown.git","ssh_url":"git@github.com:lcolladotor/blogdown.git","clone_url":"https://github.com/lcolladotor/blogdown.git","svn_url":"https://github.com/lcolladotor/blogdown","homepage":"https://bookdown.org/yihui/blogdown","size":1461,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rstudio:master","ref":"master","sha":"051efcacf0f745c9f2fc8158f47b730c741d5334","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars1.githubusercontent.com/u/513560?v=4","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":72671522,"name":"blogdown","full_name":"rstudio/blogdown","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars1.githubusercontent.com/u/513560?v=4","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/blogdown","description":"Create Blogs and Websites with R Markdown","fork":false,"url":"https://api.github.com/repos/rstudio/blogdown","forks_url":"https://api.github.com/repos/rstudio/blogdown/forks","keys_url":"https://api.github.com/repos/rstudio/blogdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/blogdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/blogdown/teams","hooks_url":"https://api.github.com/repos/rstudio/blogdown/hooks","issue_events_url":"https://api.github.com/repos/rstudio/blogdown/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/blogdown/events","assignees_url":"https://api.github.com/repos/rstudio/blogdown/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/blogdown/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/blogdown/tags","blobs_url":"https://api.github.com/repos/rstudio/blogdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/blogdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/blogdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/blogdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/blogdown/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/blogdown/languages","stargazers_url":"https://api.github.com/repos/rstudio/blogdown/stargazers","contributors_url":"https://api.github.com/repos/rstudio/blogdown/contributors","subscribers_url":"https://api.github.com/repos/rstudio/blogdown/subscribers","subscription_url":"https://api.github.com/repos/rstudio/blogdown/subscription","commits_url":"https://api.github.com/repos/rstudio/blogdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/blogdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/blogdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/blogdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/blogdown/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/blogdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/blogdown/merges","archive_url":"https://api.github.com/repos/rstudio/blogdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/blogdown/downloads","issues_url":"https://api.github.com/repos/rstudio/blogdown/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/blogdown/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/blogdown/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/blogdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/blogdown/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/blogdown/releases{/id}","deployments_url":"https://api.github.com/repos/rstudio/blogdown/deployments","created_at":"2016-11-02T18:57:35Z","updated_at":"2018-03-04T15:55:30Z","pushed_at":"2018-03-06T19:30:53Z","git_url":"git://github.com/rstudio/blogdown.git","ssh_url":"git@github.com:rstudio/blogdown.git","clone_url":"https://github.com/rstudio/blogdown.git","svn_url":"https://github.com/rstudio/blogdown","homepage":"https://bookdown.org/yihui/blogdown","size":1446,"stargazers_count":654,"watchers_count":654,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":133,"mirror_url":null,"archived":false,"open_issues_count":10,"license":null,"forks":133,"open_issues":10,"watchers":654,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/272"},"html":{"href":"https://github.com/rstudio/blogdown/pull/272"},"issue":{"href":"https://api.github.com/repos/rstudio/blogdown/issues/272"},"comments":{"href":"https://api.github.com/repos/rstudio/blogdown/issues/272/comments"},"review_comments":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/272/comments"},"review_comment":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rstudio/blogdown/pulls/272/commits"},"statuses":{"href":"https://api.github.com/repos/rstudio/blogdown/statuses/7fe6e950f7d3ffc093c6b8ae6d3787eb933eeb88"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"lcolladotor"}}