I have struggled with importing captions directly from Picasa, but I now succeded. However, I have no experience in creating patches, which is why I will try to explain in detail how I got it working.

gallery_showtime.inc:
-----------------------------------------------
add the following code before line #150 "//Get absolute path"

	// Load RSS feed from URL
	$url_to_fetch = $thisfolder;
	$xml = simplexml_load_file($url_to_fetch);
	$imagelibrary = array();
	foreach($xml->channel->item as $entry) {
		// Get the file name from the RSS feed: <enclosure type='image/jpeg' url='http://lh4.ggpht.com/_HkgjhlSfbZA/SWOgKhb6LyI/AAAAAAAABZ4/5AEu8AF01sw/DSC03173.JPG' length='0'/>
		$imagename = $entry->enclosure->attributes()->{'url'};
		// Get the file title from the RSS feed: <title>The title of the image</title>
		$imagetitle = $entry->title;			
		// Create multidimensional array with imagename and title
		$imagelibrary[] = array(
			'filename'	=> substr(strrchr($imagename, "/"), 1 ),
			'title'		=> $imagetitle
		);
	}			

Remove original line #152 "$url_to_fetch = $thisfolder;".
Remove original line #223 "// Links to full images are in this format..."
Remove original line #224 "$imgchunks = explode("' url='", $html);"

Replace original line #227 "foreach ($imgchunks as $imgchunk) {" with the following

      foreach($imagelibrary as $entry) {

Replace original lines #470-475 "if ($showcaption <> '') { ... } with the following

		if ($showcaption <> '') {
			if ($showcaption == 'title') {
				// Search multidimensional array for imagename ('$retval[$poct - 1]') and place matching 'title' in caption
				$caption = search_array($imagelibrary, 'filename', $retval[$poct - 1]);
				$caption = $caption[0]['title'];
				// If image caption has been added in Picasa the filename is added after the caption in []
				if ($caption<>$retval[$poct - 1]){$caption.=" - [".$retval[$poct - 1]."]";} else {$caption = "[".$caption."]"; }
			}
			$result .= ' title=" ' . $caption . '"';
		}

functions.inc:
---------------------------------------
Include the following function


function search_array($array, $key, $value)
{
    $results = array();

    if (is_array($array))
    {
        if (isset($array[$key]) && $array[$key] == $value)
            $results[] = $array;

        foreach ($array as $subarray)
            $results = array_merge($results, search_array($subarray, $key, $value));
    }

    return $results;
}

I have attached two updated files with the above patches included, but hope that the changes can be added to future releases of the brilliant module.

Enjoy captioning your images.

Regards,

Svend

CommentFileSizeAuthor
brilliant_gallery_patchedfiles.zip14 KBSTNyborg
Support from Acquia helps fund testing for Drupal Acquia logo