Per_page limit on post (wp:contentmedia)

Hello!

I have a post that have a gallery with more than 100 images, so the api response is something like this:

wp:contentmedia: [
{
embeddable: true,
href: "https://xxx/wp-json/wp/v2/media?include=96640,93697,93698,93699,93700,93701,93702,93703,93704,93705,93706,93707,93708,93709,93710,93711,93712,93713,93714,93715,93716,93717,93718,93719,93720,93721,93722,93723,93724,93725,93726,93727,93728,93729,93730,93731,93732,93733,93734,93735,93736,93737,93738,93739,93740,93741,93742,93743,93744,93745,93746,93747,93748,93749,93750,93751,93752,93753,93754,93755,93756,93757,93758,93759,93760,93761,93762,93763,93764,93765,93766,93767,93768,93769,93770,93771,93772,93773,93774,93775,93776,93777,93778,93779,93780,93781,93782,93783,93784,93785,93786,93787,93788,93789,93790,93791,93792,93793,93794,93795,93796,93797,93798,93799,93800,93801,93802,93803,93804,93805,93697,93701,93722,93766,93788,93770,96640&per_page=117"
}

If i enter on that url I get the following message:

 {
 code: "rest_invalid_param",
 message: "ParĂ¡metro(s) no vĂ¡lido(s): per_page",
 data: {
   status: 400,
   params: {
     per_page: "per_page debe estar entre 1 (incluido) y 100 (incluido)"}}
 }

How can I make the request on the post and limit the contentmedia restricted to 100 elements?

Thanks!

Unfortunately that’s a limitation of the WP REST API. If you have more than 100 items you have to do multiple requests.

Are you using our old plugin or are you doing the requests yourself?

This is using the default frontity request. This happens when I get the data from one post. I don’t know how to set the limit to 100 to get the data. If one post have 102 media items it returns 0 elements (on media data) because is making the 102 per_page request.

Yeah, that belongs to our old plugin then.

These are the lines where we created the query and added the media request to the REST API _links object using add_links:

wp:contentmedia is an array of arrays, so maybe you can check if sizeof($image_ids) is bigger than 100 and create multiple arrays if that happens wp:contentmedia:0, wp:contentmedia:1 … and so on.

For context, when you add _embed=true to the REST API, it takes a look at _links and it does a new request for each _link that has the embeddable: "true" field.