I'm trying to embed multiple images into simpleviewer. So far, I have been UNABLE to embed only one image, so embedding multiple doesn't seem to be happening. The bits of code I've included are inserted into a gallery-node.tpl.php file.

Here is what I am currently using which displays "You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialise correctly.":

<?php
print swf('/<?php print $node->field_gallery_image[0][filepath] ?>'); 
?>

I have been able to make simplyviewer display by inserting a direct image path such as:

<?php
print swf('/path/to/image.jpg'); 
?>

However, that only displayed simpleviewer and did not actually show the image.

If this is not a bug and simply my bad coding, sorry for marking as such; however, recommendations for fixing the code is greatly appreciated.

Comments

ron williams’s picture

Status: Active » Needs work

Using code found in the documentation on drupal.org, I've created the following which views the first 2 images in a file_field named field_gallery_image, in addition I this in a node-gallery.tpl.php file:

<?php
// Generate some playlist data which is compatible with SWF Tools.
$playlist =  swftools_prepare_playlist_data(array(''. $node->field_gallery_image[0][filename] .'', ''. $node->field_gallery_image[1][filename] .''));

// Pass the playlist data to the playlist display function.
print swf_list($playlist);

?>

The only problem is both images are required or a blank space is displayed, In addition you are limited to 2 images. I would like to move the comma to be part of the $node->field_gallery_image[#][filename] output area to prevent blank items. In addition, if someone has a recommendation for extending this past adding additional filename #'s, I would definitely appreciate it.

matt2000’s picture

<?php
$playlist = array();
foreach ($node->field_gallery_image AS $image) {
  $playlist[] = $image['filename'];
}

$playlist =  swftools_prepare_playlist_data($playlist);

print swf_list($playlist);
?>
Stuart Greenfield’s picture

The code sample from matt2000 looks good to me - did it fix your issue?

ron williams’s picture

Status: Needs work » Closed (fixed)

Yes, code did work. Matt and I were conversing via IM and I forgot to note that it worked here.

This is definitely useful and in my opinion, works as a replacement to flash gallery.

Stuart Greenfield’s picture

Component: Code » Documentation
Category: bug » task
Status: Closed (fixed) » Active

Glad it worked - I'm going to reopen the thread, and set it as a documentation task. Usage of SWF Tools seems to be taking off, and examples like this are excellent for showing how people have used it. I'd like to add this example to the docs!

Stuart Greenfield’s picture

Status: Active » Closed (fixed)

Closing this thread again as the code in #3 is no longer needed. You can use the built in CCK formatter feature to automatically send a list of images to Wijering image rotator or simpleviewer with no coding needed.