Get all attachments and filter to pdf and limit to 5
-
Hi,
I have created a controller that will fetch all attachments from the site , But the problem is that i just want attachment with mime_type of application/pdf and to limit to fetch only 5 latest uploads , so far it returns all the media . Here is my code :class json_api_getpdf_controller {
public function get_pDF() {
global $json_api;if($json_api->query->parent !== “null”)
$parent = (integer) $json_api->query->parent;
else
$output = array();
$output[‘attachments’] = $json_api->introspector->get_attachments($parent);
return $output;}
}
- The topic ‘Get all attachments and filter to pdf and limit to 5’ is closed to new replies.