
The Content methods allow you to access pieces of content in a list or a single instance.
Return a list of all content in Director. This function accepts an options array that can include any of the following parameters.
limit The number of images to return. By default, this is 0 which means all images will be returned. Using any other number will limit the results to that number.
only_images Whether to return all content (including videos) or only images. By default, all content is returned.
only_active Whether to return only active images or all images. Returns only active images by default.
sort_on How to sort the images. Options are: created_on, captured_on, modified_on, filename, random.
sort_direction Which direction to sort the content. Options are DESC or ASC.
scope An array containing the model type and id to use when filtering the results. Useful if you want to filter the results by a particular gallery or album.
# Returns the 10 most recent pieces of content for the gallery with an id of 1
$scope = array('gallery', 1);
$recently_taken = $director->content->all(array('limit' => 10, 'scope' => $scope));
tags Filter the returned content by tags that have been assigned to the content in Director. Tags should be a two-member array. The first member is a comma delimited list of tags and the second is whether the content must have all the tags listed ('all') or only one of the listed tags ('one'). Example:
# Returns only content that contains all of the following tags: water, daytime and vacation
$tags = array('water,daytime,vacation', 'all');
$recently_taken = $director->content->all(array('limit' => 10, 'tags' => $tags));
# Returns content that contains any one of the following tags: water, daytime and vacation
$tags = array('water,daytime,vacation', 'one');
$recently_taken = $director->content->all(array('limit' => 10, 'tags' => $tags));
Simple example of the all method in use.
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recently_taken = $director->content->all(array('limit' => 10));
foreach($recently_taken as $image) {
echo '<img src="' . $image->original->url . '" />';
}
?>
Returns a single piece of content.
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$content = $director->content->get(1);
echo '<img src="' . $content->original->url . '" />';
?>