1 | import cloudinary from 'SRC/services/cloudinary'
|
2 |
|
3 | export const swatchUrl = (colorway, overrides = {}) => {
|
4 | let shot = colorway.shots.find((s) => {
|
5 | return s.shot_type === 'front'
|
6 | })
|
7 | if (!shot) {
|
8 |
|
9 | shot = colorway.shots[0]
|
10 | }
|
11 |
|
12 | const url = colorway.swatch_cloudinary_key || shot.cloudinary_key
|
13 | let defaults = { format: 'jpg' }
|
14 |
|
15 | if (!colorway.swatch_cloudinary_key) {
|
16 | defaults.transformation = 'swatch_v2'
|
17 | }
|
18 |
|
19 | return cloudinary.url(url, { ...defaults, ...overrides })
|
20 | }
|