{"action":"created","issue":{"url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/38","labels_url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/38/comments","events_url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/38/events","html_url":"https://github.com/wp-shortcake/image-shortcake/issues/38","id":84820827,"number":38,"title":"Transform `<img>` to `[img]` on the fly with shortcode reversal","user":{"login":"danielbachhuber","id":36432,"avatar_url":"https://avatars.githubusercontent.com/u/36432?v=3","gravatar_id":"","url":"https://api.github.com/users/danielbachhuber","html_url":"https://github.com/danielbachhuber","followers_url":"https://api.github.com/users/danielbachhuber/followers","following_url":"https://api.github.com/users/danielbachhuber/following{/other_user}","gists_url":"https://api.github.com/users/danielbachhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/danielbachhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielbachhuber/subscriptions","organizations_url":"https://api.github.com/users/danielbachhuber/orgs","repos_url":"https://api.github.com/users/danielbachhuber/repos","events_url":"https://api.github.com/users/danielbachhuber/events{/privacy}","received_events_url":"https://api.github.com/users/danielbachhuber/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wp-shortcake/image-shortcake/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-03T23:41:14Z","updated_at":"2015-11-23T14:57:32Z","closed_at":null,"body":"We should have some option for transparently converting `<img>` to `[img]` on the fly using shortcode reversal when the post is saved."},"comment":{"url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/comments/158960054","html_url":"https://github.com/wp-shortcake/image-shortcake/issues/38#issuecomment-158960054","issue_url":"https://api.github.com/repos/wp-shortcake/image-shortcake/issues/38","id":158960054,"user":{"login":"goldenapples","id":665992,"avatar_url":"https://avatars.githubusercontent.com/u/665992?v=3","gravatar_id":"","url":"https://api.github.com/users/goldenapples","html_url":"https://github.com/goldenapples","followers_url":"https://api.github.com/users/goldenapples/followers","following_url":"https://api.github.com/users/goldenapples/following{/other_user}","gists_url":"https://api.github.com/users/goldenapples/gists{/gist_id}","starred_url":"https://api.github.com/users/goldenapples/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldenapples/subscriptions","organizations_url":"https://api.github.com/users/goldenapples/orgs","repos_url":"https://api.github.com/users/goldenapples/repos","events_url":"https://api.github.com/users/goldenapples/events{/privacy}","received_events_url":"https://api.github.com/users/goldenapples/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T14:57:32Z","updated_at":"2015-11-23T14:57:32Z","body":"@vralle - nice, thanks! \r\n\r\nThere are a few things in there that I don't think we can really depend on in many production environments... like being able to query for all attachments at once and loop through them. But something along those lines will be necessary in order to get beyond the [naive regex](https://github.com/wp-shortcake/image-shortcake/blob/master/inc/class-img-shortcode-data-migration.php#L11-L26) that we're currently using to match image tags to the attachment ids.\r\n\r\nI do also like the looping through the generated attachment sizes to try to match the filename of the img src to the filename of a specific crop size. I think we can probably do something like that in any migration/reversal script that lands in here.\r\n\r\nDo you have time to try and put together a pull request that does this? The pattern we've been following with Shortcake is to include a \"reversal\" function (stubbed out [here](https://github.com/wp-shortcake/image-shortcake/blob/master/inc/class-img-shortcode-data-migration.php#L11-L26), which is [hooked onto `pre_kses`](https://github.com/wp-shortcake/image-shortcake/blob/master/inc/class-img-shortcode-data-migration.php#L11-L26) and, taking the content string as input, returns the content with all tags that can be replaced with shortcodes replaced.\r\n\r\n"}}