unpic icon indicating copy to clipboard operation
unpic copied to clipboard

Support for Cockpit CMS

Open mikekok opened this issue 1 year ago • 3 comments

Support for Cockpit CMS would be nice. Their API is pretty straightforward.

image

mikekok avatar Jan 02 '25 22:01 mikekok

Can the URLs be manually constructed? Unpic needs the transformer to be a pure, synchronous function with no side effects, so it can't call APIs.

ascorbic avatar Jan 03 '25 09:01 ascorbic

Can the URLs be manually constructed? Unpic needs the transformer to be a pure, synchronous function with no side effects, so it can't call APIs.

The URL can indeed be constructed. It works the same way as Directus, Shopify etc, by generating an image on the fly, based on the URL parameters (as shown in the picture).

Here's the parameters you'd use to get a 500x500 webp image: https://example.com/api/assets/image/2fd457c3376537fb3d0001e2?w=500&h=500&mime=webp&re=1

More specifically: width = w height = h format = mime crop = m

You always have to add re=1 as a parameter in order to be redirected to the actual image.

mikekok avatar Jan 03 '25 11:01 mikekok

OK, great. If anyone wants to contribute it they should do so against the new syntax branch which includes uopdated instrucitons on contributing them. It looks like a relatively simple one.

ascorbic avatar Jan 03 '25 11:01 ascorbic