unite-cms icon indicating copy to clipboard operation
unite-cms copied to clipboard

Image resize Urls for different breakpoints

Open stefan-kamsker opened this issue 7 years ago • 7 comments

i haven't used thumbnail_url on image field type until now :).

It seems that this option only handles the small image previews in unite cms and is not available over the graphQL api. (would also not make so much sense as it would only be one resized image version)

preview graphql

I think we should extend image type to deliver multiple versions of the image, most resizing services do have a similar url pattern.

only pseudo code

 {
          "title": "Image",
          "identifier": "image",
          "type": "image",
          "settings": {
            "bucket": {
              "endpoint": "https://xxxx",
              "bucket": "stefan",
              "key": "xxxx",
              "secret": "xxxxxx",
              "path": "test"
            },
            "presets": {
              "maxwidth480":  { 
                 "url": "https://my_image_resize_service.com/width/480/x/[URL]",

               },
              "maxwidth1280":  { 
                 "url": "https://my_image_resize_service.com/width/1280/x/[URL]",
               }
             }
          }
 }

fe. to feed a html picture element https://www.w3schools.com/tags/att_source_srcset.asp

would be very handy on the frontend side

@franzwilding what do you think?

stefan-kamsker avatar Oct 10 '18 21:10 stefan-kamsker

Why don’t do this on the client side?

franzwilding avatar Oct 11 '18 05:10 franzwilding

My thought yesterday was:

if there is already an option to specifiy a thumbnailing service (even it's only for unite cms interface) why not make it more handy for (in my opinion) most use cases (3-4 different image versions) to allow specifying some presets which will already return the right urls. Very likely i will use the same thumbnail service for my client apps.

But we can leave this part on the client side as well.

stefan-kamsker avatar Oct 11 '18 07:10 stefan-kamsker

I see. I think this can be useful in some cases. In other cases, where for example the thumbnail service will define the presets, this would not be needed, because you can already use the preset name from the client app.

Anyway, we can add the presets as an optional config for anyone who wants to use it, good idea! How would this work with the already existing thumbnail_url? Would it replace it?

franzwilding avatar Oct 11 '18 07:10 franzwilding

You're right, not usefull for all cases.

How would this work with the already existing thumbnail_url? Would it replace it?

Yes i would do a different config, something like

 {
          "title": "Image",
          "identifier": "image",
          "type": "image",
          "settings": {
            "bucket": {
              "endpoint": "https://xxxx",
              "bucket": "stefan",
              "key": "xxxx",
              "secret": "xxxxxx",
              "path": "test"
            },
            "presets": {
              "maxwidth200":  { 
                 "url": "https://my_image_resize_service.com/width/200/x/[URL]",
               },
              "maxwidth480":  { 
                 "url": "https://my_image_resize_service.com/width/480/x/[URL]",
               },
              "maxwidth1280":  { 
                 "url": "https://my_image_resize_service.com/width/1280/x/[URL]",
               }
             },
             "maintenance_preset": "maxwidth200",
          }
 }

Or the wanted maintenance preset has to be defined on the unite cms view (sortable, table etc.), which would be much cleaner and flexible.

One advantage would also be to have different image versions available also in unite cms fe. bigger thumbs, smaller thumbs for different interfaces

Priority low.

stefan-kamsker avatar Oct 11 '18 07:10 stefan-kamsker

So instead of:

{
    "thumbnail_url": "https://my_image_resize_service.com/width/200/x/[URL]",
}

I would need to write

{
    "resets": {
       "foo": {
           "url": "https://my_image_resize_service.com/width/200/x/[URL]"
       },
       "maintenance_preset": "foo"
   }
}

?

Why not leave the thumbnail_url as it is and just add the presets option?

franzwilding avatar Oct 11 '18 07:10 franzwilding

Also an option. The question is: Do we need differnent image versions in unite cms itself (fe. in the future), or is one enough?

See my comment above:

Or the wanted maintenance preset has to be defined on the unite cms view (sortable, table etc.), which would be much cleaner and flexible.

stefan-kamsker avatar Oct 11 '18 07:10 stefan-kamsker

Not yet, but if we need different image versions in the future, all of them would be distinctly named. So we could add them as thumbnail_url, big_thumbnail_url etc.

franzwilding avatar Oct 11 '18 07:10 franzwilding