Help needed regarding REST API population for image format size

I am using an image field in one of my collection types and would like to pull just the data for just one of the format sizes but am unable to do this. I am using a JavaScript query with the qs library.

The following successfully pulls in all the formats:


		const params = {
			sort: ['title:asc'],
			filters: {
				title: {
					$eq: 'Blah'
				}
			},
			fields: ['title'],
			populate: ['image']
		};

Looking at the docs I thought that this should work and just get data for the small format, but it return all the format sizes:

		const params = {
			sort: ['title:asc'],
			filters: {
				title: {
					$eq: 'Blah'
				}
			},
			fields: ['title'],
			populate: {
				image: {
					populate: {
						formats: ['small']
					}
				}
			}
		};

Any suggestions would be greatly appreciated.

Edit - ChatGPT suggested this, but it didn’t work either unfortunately:

		populate: {
				'image.formats.medium': {
					select: ['url', 'width', 'height', 'size']
				}
			}

@j_p There isn’t any way to populate particular format size image.
The formats field is a single field and it stores the whole json object containing different images sizes.

@Shekhar Ah, ok, that explains it then - thanks for the info :slight_smile:

1 Like