« Back to slideshowpro.net
SlideShowPro Help Wiki
Recent changes / Search

SlideShowPro for Flash

SlideShowPro for Lightroom

SlideShowPro Director

SlideShowPro Director Hosting

Extras

Screencasts

SlideShowPro Director
Example: Recently uploaded images
Page last modified by bdaily on July 24, 2008, at 09:23 PM

Once you have successfully connected to the API using the DIrectorPHP class, there is a world of data and imagery at your fingertips. To get acquainted with how the DirectorPHP class works, let's walk through a simple example which will show the most recently uploaded content from Director.

If you followed the getting started example, you should already have this in your index.php file:

<?php
  include('classes/DirectorPHP.php');
  $director = new Director('your-api-key', 'your-api-path');

  echo('Connected!');
?>

Now it's time to fetch some content from Director. We use the content subclass to do that:

<?php
  include('classes/DirectorPHP.php');
  $director = new Director('your-api-key', 'your-api-path');

  $recent = $director->content->all(array('limit' => 10));
?>

Our new line of code requests the 10 most recent pieces of content from our Director installation. We can now output the full size originals to the page:

<?php
  include('classes/DirectorPHP.php');
  $director = new Director('your-api-key', 'your-api-path');

  $recent = $director->content->all(array('limit' => 10));

  foreach($recent as $content) {
    echo '<img src="' . $content->original->url . '" />';
  }
?>

If you have uploaded videos recently, you will notice that they show up in the list as well. The all() method allows you to specify that you only want images:

<?php
  include('classes/DirectorPHP.php');
  $director = new Director('your-api-key', 'your-api-path');

  $recent = $director->content->all(array('limit' => 10, 'only_images' => true));

  foreach($recent as $content) {
    echo '<img src="' . $content->original->url . '" />';
  }
?>

So now you have a list of recent images, but who wants to display several megabyte original images in a list like this? In our next example, we'll use the DirectorPHP class to tap into Director's powerful on-demand image processing library.

© 2008 Dominey Design Inc. All Rights Reserved.
About | Contact | Privacy policy | License agreements