{"action":"created","issue":{"url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/24","labels_url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/24/comments","events_url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/24/events","html_url":"https://github.com/cryogen-project/cryogen-core/issues/24","id":86985942,"number":24,"title":"image handling in Post is generally broken","user":{"login":"zerg000000","id":910506,"avatar_url":"https://avatars.githubusercontent.com/u/910506?v=3","gravatar_id":"","url":"https://api.github.com/users/zerg000000","html_url":"https://github.com/zerg000000","followers_url":"https://api.github.com/users/zerg000000/followers","following_url":"https://api.github.com/users/zerg000000/following{/other_user}","gists_url":"https://api.github.com/users/zerg000000/gists{/gist_id}","starred_url":"https://api.github.com/users/zerg000000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerg000000/subscriptions","organizations_url":"https://api.github.com/users/zerg000000/orgs","repos_url":"https://api.github.com/users/zerg000000/repos","events_url":"https://api.github.com/users/zerg000000/events{/privacy}","received_events_url":"https://api.github.com/users/zerg000000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-10T14:18:20Z","updated_at":"2015-06-12T06:57:59Z","closed_at":null,"body":"First, I have a hard time when i try to include images in markdown\r\n, when I am following the instructions from [Including Images in Posts](http://cryogenweb.org/docs/writing-posts.html).\r\n\r\n1. Missing resources/public/img/xxxx.jpg\r\n\r\n    The source of the problem is the `copy-images-from-markdown-folders`  will never \r\n    create the folder `resources/public/img/` when it does not exist, so the `io/copy` will fail forever.\r\n    ```clojure\r\n    (defn copy-images-from-markdown-folders [{:keys [blog-prefix]}]\r\n      (doseq [asset (fs/find-files \"resources/templates/md\" #\".+(jpg|jpeg|png|gif)\")]\r\n        (io/copy asset (io/file (str public blog-prefix \"/img/\" (.getName asset))))))\r\n    ```\r\n    Finally, I avoid this bug by creating `img` folder in `resources/templates` adding this line to `config.edn`\r\n    ```clojure\r\n     :resources        [\"css\" \"js\" \"img\" \"404.html\"]\r\n    ```\r\n2. Naming conflict for posts images\r\n\r\n    Since all posts' image will be flatten into `/img/`, the images with same name will be overwritten.\r\n\r\n3. Not supporting all image formats which widely supported\r\n\r\n    Bottom line, SVG should be supported by the copying function.\r\n\r\n4. Inconsistent image handling for Asciidoc\r\n\r\n    As the copy-images-from-markdown-folders` function name implied, only images in `/md/` folder   will be copied. This raise the question, where should I place my post's images for Asciidoc posts?\r\n\r\n### Solution\r\n\r\nReplace `copy-images-from-markdown-folders` with function\r\n\r\n```clojure\r\n(defn copy-post-assets [config] ...)\r\n```\r\n\r\nThe function will copying posts' resources like\r\n\r\nfrom                                    |                             to       \r\n------------------------------------|-----------------------------------------------------------------                                      \r\n`posts/goodpost/abc.png`  |  `resources/public/post-assets/goodpost/abc.png`\r\n`posts/anotherpost/b.gif`   |  `resources/public/post-assets/anotherpost/b.gif` \r\n`posts/anotherpost/a.zip`   |  `resources/public/post-assets/anotherpost/a.zip`\r\n\r\nThe advantages are \r\n\r\n* no naming conflict \r\n* consistent between asciidoc and markdown\r\n* generally apply to all file type\r\n* open chance to support different folder structure like `/posts/2015/12/11/my-post.html`\r\n* actually, implementation is just reuse the `copy-resources` function\r\n"},"comment":{"url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/comments/111384472","html_url":"https://github.com/cryogen-project/cryogen-core/issues/24#issuecomment-111384472","issue_url":"https://api.github.com/repos/cryogen-project/cryogen-core/issues/24","id":111384472,"user":{"login":"zerg000000","id":910506,"avatar_url":"https://avatars.githubusercontent.com/u/910506?v=3","gravatar_id":"","url":"https://api.github.com/users/zerg000000","html_url":"https://github.com/zerg000000","followers_url":"https://api.github.com/users/zerg000000/followers","following_url":"https://api.github.com/users/zerg000000/following{/other_user}","gists_url":"https://api.github.com/users/zerg000000/gists{/gist_id}","starred_url":"https://api.github.com/users/zerg000000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerg000000/subscriptions","organizations_url":"https://api.github.com/users/zerg000000/orgs","repos_url":"https://api.github.com/users/zerg000000/repos","events_url":"https://api.github.com/users/zerg000000/events{/privacy}","received_events_url":"https://api.github.com/users/zerg000000/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T06:57:59Z","updated_at":"2015-06-12T06:57:59Z","body":"AvisoNovate/cryogen-core seems to have all fixes in his fork."}}