
The Utilities methods are useful functions for working with Director data.
Check if a piece of content is a video.
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(10);
foreach($recent as $content) {
$out = $content->src . ' is a ';
if ($director->utils->is_video($content->src)) {
$out .= 'video';
} else {
$out .= 'image';
}
echo $out . '<br />';
}
?>
The same as is_video, except returns true if the content is an image.
Truncate a long string to a given character limit.
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(10);
foreach($recent as $content) {
echo $content->src . '<br />';
echo $director->utils->truncate($content->caption) . '<br /><br />';
}
?>
Converts the line breaks in a string to paragraph tags and HTML breaks.
<?php
include('classes/DirectorPHP.php');
$director = new Director('your-api-key', 'your-api-path');
$recent = $director->content->all(10);
foreach($recent as $content) {
echo '<h1>' . $content->src . '</h1>';
echo $director->utils->convert_line_breaks($content->caption);
}
?>