{"action":"created","issue":{"url":"https://api.github.com/repos/bolt/bolt/issues/3703","repository_url":"https://api.github.com/repos/bolt/bolt","labels_url":"https://api.github.com/repos/bolt/bolt/issues/3703/labels{/name}","comments_url":"https://api.github.com/repos/bolt/bolt/issues/3703/comments","events_url":"https://api.github.com/repos/bolt/bolt/issues/3703/events","html_url":"https://github.com/bolt/bolt/issues/3703","id":89012477,"number":3703,"title":"[RFC] New way of thumbnails generation","user":{"login":"Boorj","id":2145313,"avatar_url":"https://avatars.githubusercontent.com/u/2145313?v=3","gravatar_id":"","url":"https://api.github.com/users/Boorj","html_url":"https://github.com/Boorj","followers_url":"https://api.github.com/users/Boorj/followers","following_url":"https://api.github.com/users/Boorj/following{/other_user}","gists_url":"https://api.github.com/users/Boorj/gists{/gist_id}","starred_url":"https://api.github.com/users/Boorj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Boorj/subscriptions","organizations_url":"https://api.github.com/users/Boorj/orgs","repos_url":"https://api.github.com/users/Boorj/repos","events_url":"https://api.github.com/users/Boorj/events{/privacy}","received_events_url":"https://api.github.com/users/Boorj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bolt/bolt/labels/Bolt%20Library%20Issue","name":"Bolt Library Issue","color":"5319e7"},{"url":"https://api.github.com/repos/bolt/bolt/labels/Feature","name":"Feature","color":"90A959"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-06-17T13:09:48Z","updated_at":"2016-02-22T18:09:25Z","closed_at":"2015-12-13T13:35:14Z","body":"### Intro\r\nCurrent way of thumbnails generation has several disadvantages\r\n**1**. it's insecure to let any visitor to create any image by request. If you have /images/1.jpg, server space can be filled with requesting for \r\n> /thumbs/**1x1**/1.jpg\r\n> /thumbs/**1x2**/1.jpg\r\n> /thumbs/**1x3**/1.jpg\r\n\r\n**2**.  If you have several implementations of your thumbnail size in twig template and willing to change resolution of the thumbs, you have to change this resolution in each place.\r\n> {{ record.photo|showimage(800, 600) }}\r\n> // 800 and 600 has to be changed everywhere\r\n\r\n**3**. If you want to do some other transformations (like black and white processing or crop) - you also have to change it.\r\n\r\n**4**. Case: you have 100mb serverspace free. Each thumbnail is about 50kb, when you have 20000 thumbnails generated, server space is busy.\r\nWithout a thumbnail generation tool (like cache:clear) or nut command - it could happen unexpectedly.\r\n\r\n**5**. Folders for thumbnails are heavily hardcoded. It would be have flexibility to setup naming thumbnail folders.\r\n\r\n**6**. Case: i want to let user upload huge images, but don't want them to be available in web folder. Only resized versions or versions with some watermarking. How can i restrict access to original images? i think it could be achieved with **5** by setting folder for uploads outside the web wolder.\r\n\r\n### Proposal:\r\nMake a thumbnail (resize , process) config  for each image/imagelist contenttype.\r\n```yaml\r\n#contenttypes:\r\nuser_contenttype:\r\n    photo:\r\n        label: \"It's a photo, dude\"\r\n        type: image\r\n        resizes:\r\n            resize1:\r\n                size: [320,200] # other setting are set by default\r\n            preview:\r\n                size: [800,600]\r\n                upscale: false\r\n                format: 'jpg'\r\n                type: 'stretch' # 'fit' / 'fill' / 'crop'\r\n            thumbnail_renamed_and_processed: \r\n                size: [200,166]\r\n                filename: \"%date%_%dimensions%.%original_extension%\"\r\n                folder: \"%thumbs_folder%/carrots\" # relatively to %web_folder%\r\n```\r\nand so it will be used like\r\n```twig\r\n{{ record.photo|thumb('resize1')}}\r\nor dynamic filter generation (just a fantasy :)\r\n{{ record.photo|preview}}\r\nor perhaps\r\n{{ record.photo__thumbnail_renamed_and_processed}}\r\n```\r\n\r\n### Backwards Compatibility\r\nI think for a while it could be used in special mode in config, that is set by default to old style of thumbnail generation. And if you want to use the new style - just add \r\n```yaml\r\n#config.yml\r\nnew_thumbs_or_whatever: true\r\n```"},"comment":{"url":"https://api.github.com/repos/bolt/bolt/issues/comments/187298838","html_url":"https://github.com/bolt/bolt/issues/3703#issuecomment-187298838","issue_url":"https://api.github.com/repos/bolt/bolt/issues/3703","id":187298838,"user":{"login":"rarila","id":5936174,"avatar_url":"https://avatars.githubusercontent.com/u/5936174?v=3","gravatar_id":"","url":"https://api.github.com/users/rarila","html_url":"https://github.com/rarila","followers_url":"https://api.github.com/users/rarila/followers","following_url":"https://api.github.com/users/rarila/following{/other_user}","gists_url":"https://api.github.com/users/rarila/gists{/gist_id}","starred_url":"https://api.github.com/users/rarila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rarila/subscriptions","organizations_url":"https://api.github.com/users/rarila/orgs","repos_url":"https://api.github.com/users/rarila/repos","events_url":"https://api.github.com/users/rarila/events{/privacy}","received_events_url":"https://api.github.com/users/rarila/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T18:09:25Z","updated_at":"2016-02-22T18:09:25Z","body":"@GDmac hmm, after rethinking we probably don't interfere at all as my stuff is backend contenttype listings (and later file browser thumbnails) only.\r\n\r\nAnd yes, allowing arbitrary sizes does only makes sense using the ``0`` auto parameter."}}