Open moskyow opened 2 years ago
MediaQueryBuilder
by default paginates your result. The default page is 1 and default results per page are 10. Have a look at Page
and PerPage
property of MediaQueryBuilder
.
You can loop through the pages to get all the required media. Alternatively, you can also use the GetAll
method that you mentioned.
MediaQueryBuilder
by default paginates your result. The default page is 1 and default results per page are 10. Have a look atPage
andPerPage
property ofMediaQueryBuilder
.You can loop through the pages to get all the required media. Alternatively, you can also use the
GetAll
method that you mentioned.
Thank you, I see that also PostsQueryBuilder have the same default 10 posts per page. How I can find the collection of Pages for media and posts returned by the query to loop ?
You will have to add a for loop in your code and then increment the page number for the query builder for each iteration of your for loop and then call the Query
method. This will then issue a http request for each iteration and give back the results.
Also, you can set the PerPage
to 100 (this is the max value supported by Wordpress Rest api). This way you will get 100 Media/Posts for each iteration of for loop.
You will have to add a for loop in your code and then increment the page number for the query builder for each iteration of your for loop and then call the
Query
method. This will then issue a http request for each iteration and give back the results.Also, you can set the
PerPage
to 100 (this is the max value supported by Wordpress Rest api). This way you will get 100 Media/Posts for each iteration of for loop.
Thank you. Ok, I can increment the Page and repeat the request for each loop, but can I know the maximum number of pages to loop ? If I must have the total number of media by GetAll method, the query is useless.
Ok, resolved. I check if the page that I loop have or not the number of Media equals at PerPage number. It seems that GetAll returns all media_type, but the Query only image file. It's a bug or a default setting ?
Yes, by default it only queries images because the MediaQueryType
is set to Image by default. @ThomasPe is it expected for media query builder to give only images?
I don't see where it would be set to images by default, is this a fallback of the API? I would be fine with the Query Builder returning all types by default.
The MediaType
property in the MediaQueryBuilder
is of MediaQueryType
enum type. Enums by default are set to the first item of the enum which in case of MediaQueryType
is Image
. So, if a MediaQueryBuilder
object is created without setting the MediaType
property, then this property is by default set to Image.
We also have a test Media_Query
in Media_Tests
class which confirms that the url contains the media_type=image substring causing only images to return.
I don't see where it would be set to images by default, is this a fallback of the API? I would be fine with the Query Builder returning all types by default.
On my code I use MediaQueryBuilder, but it return only images
I just published a new 2.0.0-beta.2 for release 2 that includes a bugfix from @navjot50 (Thanks!) which allows you to pass "All" as an enum to the query builder. Let me know if this helped!
Hi, with vb.net With the following code the query return only 10 Media of the current year, also if i set the value of year "before" on 2012 (cboAnno.text) The number media I return with method GetAll is more than 400
What is the problem ?