Topic: Juicebox and Drupal with Picasa album

Hi,

Does anyone is this forum has experience with integrating the Juicebox-plugin into Drupal, but based on a Picasa gallery?
The images reside on a Picasa (Google+) gallery but I would like to expose them using Juicebox from within Drupal.

Is there some documentation available on this topic?

Best regards,
Mark

Re: Juicebox and Drupal with Picasa album

As far as I am aware, the Juicebox module for Drupal does not support Picasa/Google+ as a source of images.
Please note that we did not write the module ourselves and, as such, I am not familiar with its source code and do not know how easy or difficult it might be to add such functionality.
You might like to post in the Drupal forum where the author of the module might be able to help you further.

In the meantime, here are some notes which might help.

Below is some sample PHP code which can be used to fetch images from Picasa/Google+ and display them in a Juicebox gallery.
To see the example in action:
(1) Enter your own Picasa User Id and Picasa Album Name on lines 38 and 39 of the code below.
(2) Put the code in a file named 'config.php' and place the file in your gallery folder (in the same directory as the page containing the gallery's embedding code).
(3) Add configUrl: 'config.php', to your gallery's embedding code, for example:

<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
    new juicebox({
        containerId: 'juicebox-container',
        configUrl: 'config.php'
    });
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

Now just open the gallery's web page in your browser and your Picasa/Google+ images should be displayed.
(The code also uses the Picasa images's 'title' as the Juicebox image title and the Picasa image's 'summary' as the Juicebox image caption.)

You could use the baseUrl method to embed your galleries into your Drupal pages manually (please see the Embedding in a Drupal Site support section for details) and use the technique above to display your Picasa/Google+ images.
This might be easier than trying to modify the Drupal module to accept a new source of images.

Here is the 'config.php' file code:

<?php
header('Content-type: application/xml');

function get_attachments_picasa($picasa_user_id, $picasa_album_name) {
    $attachments = array();
    $name = remove_whitespace($picasa_album_name);
    $term = preg_match('/^[0-9]{19}$/', $name) ? 'albumid' : 'album';
    $picasa_feed = 'http://picasaweb.google.com/data/feed/api/user/' . remove_whitespace($picasa_user_id) . '/' . $term . '/' . $name . '?kind=photo&amp;imgmax=1600';
    $entries = @simplexml_load_file($picasa_feed);
    if ($entries) {
        foreach ($entries->entry as $entry) {
            $attachments[] = $entry;
        }
    }
    return $attachments;
}

function remove_whitespace($input) {
    return preg_replace('/\\s+/', '', $input);
}

function line_break($input) {
    return preg_replace('/\r\n|\r|\n/', '<br />', $input);
}

function strip_control_characters($input) {
    $output = @preg_replace('/\p{Cc}+/u', '', $input);
    return $output ? $output : $input;
}

$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;

$settings_tag = $dom_doc->createElement('juiceboxgallery');

$custom_values = array();

$custom_values['e_picasaUserId'] = 'PicasaTeam';
$custom_values['e_picasaAlbumName'] = 'VegasWeekend';

$attachments = get_attachments_picasa($custom_values['e_picasaUserId'], $custom_values['e_picasaAlbumName']);

foreach ($attachments as $attachment) {
    $media = $attachment->children('http://search.yahoo.com/mrss/');
    $media_group = $media->group;
    $image_url = $media_group->content->attributes()->{'url'};
    $thumb_url = $media_group->thumbnail[1]->attributes()->{'url'};
    $image_element = $dom_doc->createElement('image');
    $image_element->setAttribute('imageURL', $image_url);
    $image_element->setAttribute('thumbURL', $thumb_url);
    $image_element->setAttribute('linkURL', $image_url);
    $image_element->setAttribute('linkTarget', '_blank');
    $title_element = $dom_doc->createElement('title');
    $image_title = $attachment->title;
    $image_title = line_break($image_title);
    $image_title = strip_control_characters($image_title);
    $title_text = $dom_doc->createCDATASection($image_title);
    $title_element->appendChild($title_text);
    $image_element->appendChild($title_element);
    $caption_element = $dom_doc->createElement('caption');
    $image_caption = $attachment->summary;
    $image_caption = line_break($image_caption);
    $image_caption = strip_control_characters($image_caption);
    $caption_text = $dom_doc->createCDATASection($image_caption);
    $caption_element->appendChild($caption_text);
    $image_element->appendChild($caption_element);
    $settings_tag->appendChild($image_element);
}

$dom_doc->appendChild($settings_tag);

echo $dom_doc->saveXML();
?>

I hope this helps.

Re: Juicebox and Drupal with Picasa album

As someone who has traveled this road ... converting from Photos on Google Photos (aka, Picasaweb aka Google+ Photos) your path of least resistance and most functionality might be to just arrange the photos in folders on your desktop computer, then use Juicebox Builder to build your galleries from the pics on your desktop and upload the appropriate galleries to your Drupal web site.  This way you are not (long term) held hostage to whatever access decisions Google makes.  The Picasa desktop product provides a good way to get your Google Photos files arranged on your desktop prior to making Juicebox Galleries out of them.  I had a pretty productive workflow going to create 50+ Juicebox galleries on my Drupal 8 web site ... organize the folders, use juicebox builder to create galleries, upload selected files to your site using FTP.  You really only need to upload the xml file and images and thumbnails directories to your site if you have the Drupal juicebox module set up there.  I created a menu for all my galleries too.

fkelly.org for an example.

Re: Juicebox and Drupal with Picasa album

@fkelly12054

Many thanks for sharing your experiences and web site link.

Re: Juicebox and Drupal with Picasa album

@fkelly12054

Thanks for sharing!

Regards,
Mark

Re: Juicebox and Drupal with Picasa album

My pleasure to help.  The juicebox support people (as well as on Drupal) here have been really responsive and got me going, so I'm glad to give back.

For what it's worth, since this thread started Google has announced the end of support for both Picasa Desktop and Picasaweb.  Supposedly there will be a web place where you can still access Picasaweb pictures but how that plays out is an unknown.  The google forums are filled with people looking for a way out.  I've recommended Juicebox over there.  You might see a nice influx of new business from that (not my recommendation per se but just the fact that a lot of people should be fleeing Google and its incompetent administration of photos and its total focus on smartphone photo support).

Re: Juicebox and Drupal with Picasa album

I've recommended Juicebox over there.

That's awesome! Thanks for that! :)