| parseAttachements: (item, baseUrl, images, documents) => { | |
| images = images || []; | |
| documents = documents || []; | |
| return _.mapValues(item, (v, k) => { | |
| const parse = baseUrl => type => (attachement, size) => | |
| self.attachementUrl(baseUrl, type, attachement, size); | |
| const parsePreview = parse(baseUrl)('preview'); | |
| const parseStatic = parse(baseUrl)('static'); | |
| if(images.indexOf(k) != -1 && k === 'highResImage' && v) { | |
| return parsePreview(v, 1800) | |
| } ; | |
| if(images.indexOf(k) != -1) { | |
| if(_.isArray(v) ) { | |
| return _.map(v, c => { | |
| if(c.image) { | |
| c.image = parsePreview(c.image, 500); | |
| } | |
| return c; | |
| }); | |
| } | |
| if(k !== 'highResImage') { return parsePreview(v, 500); } | |
| } | |
| if(documents.indexOf(k) != -1 && v) { | |
| return parseStatic(v); | |
| } | |
| //make sure to return false for those properties that were untouched | |
| if(documents.indexOf(k) != -1 || images.indexOf(k) != -1) | |
| { return false; } | |
| //make sure to return all other values untouched | |
| return v; | |
| }); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment