Hello,
I’ve started using Cockpit for my single page app, which is a simple portfolio: title, description, gallery. I have kind of main page, with small thumbnail of each project.
What I need is to attach url to thumbnail of specific size, for each entry, INSIDE response of ‘/api/collections/get…’. I don’t want to use ‘/api/cockpit/image…’, because as far as I understand I would have to use it X times in a row.
I know PHP a bit and I’m not afraid to mess a bit inside files, with a little help and advice where to look for.
I see it like this: I have a field of Image type with defined name (ie. ‘featuredImage’). Then I put inside PHP rules to create thumbnail of this particular image, put its URL inside entry data (ie. ‘_thumbnailURL’) and attach this field to the API response every time.
Have you looked to the ImageStyles addon - https://github.com/pauloamgomes/ImageStyles ? It provides way a simple way to define styles (e.g. thumbnail, banner, etc…) and the corresponding image urls will be returned automatically.
@pauloamgomes, this looks promising. I’m gonna try it.
@artur, I might have misunderstood the idea earlier, I was thinking that this approach will give me only the urls, then I need to send request again for the image itself in the .
However it would be nice to receive one complex response of entries with their image urls and get rid of putting token and full path again in each img.