Is it possible to associate a field with a an image caption? I noticed some code but I don't know how to populate it.

<div class="galleria-info">
<div class="galleria-info-link"></div>
<div class="galleria-info-text">
<div style="display: none;" class="galleria-info-title"></div>
<div style="display: none;" class="galleria-info-description"></div><div style="display: none;" class="galleria-info-author">
</div></div>
<div class="galleria-info-close"></div></div>

CommentFileSizeAuthor
#5 custom.zip6.17 KBAdam S
#3 galleria-skin.jpg67.42 KBAdam S
#3 custom.zip6.21 KBAdam S
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Adam S’s picture

I just discovered that the text attribute creates the caption. Still it would be nice to have some functionality to manage caption text with the Galleria plugin. National Geographic implements jCarousel, Galleria and body text for a lot of it's content. I think its rather cool. http://www.nationalgeographic.com/nationalgeographic.com/geography-of-di...

BTW, it's a great module and I will be testing it.

aaron’s picture

Version: 6.x-1.0-alpha1 » 6.x-1.x-dev

i'm working out how specifically to do that right now. basically, we need to pass a js function to the plugin telling it where to find the caption when it's not in the default title attribute. my experiments aren't working yet, but it is in my @todo list. i'll have to see if i can generalize it for any basic view, or if it'll require a site-specific override in the slideshow options, but i'll post my solution on this ticket.

Adam S’s picture

FileSize
6.21 KB
67.42 KB

I was mucking around with javascript and css both of which I know little about and created this monster of a template. At first it didn't work on the iPhone but now it does. Who knows?

plastikkposen’s picture

Adam S

Looks fantastic. Where does your files in the ZIP file actually go? (directory)

thanks :-)

Adam S’s picture

FileSize
6.17 KB

I made a post about how I made the Galleria on my site. http://drupal.org/node/856990#comment-3216058 (How cool is the photo???)

If you try it, make some notes because this would be a good contribution to Drupal documentation.

I attached the latest version of my custom theme because I've done a lot of work on it since.

plastikkposen’s picture

How do you enable your custom plugin???

-Thanks

aaron’s picture

espen.skalle: to add a custom theme/skin, you'll need to add that skin to your sites/all/libraries folder, then paste the path in the custom theme section of the galleria options.

thanks for the great theme, adam!

Adam S’s picture

The theme could use a little work making sure that it functions in Opera.

thinguy’s picture

Not sure it it's not working or I have the path wrong.
I use custom for the custom theme name and sites\all\libraries\galleria\src\themes\custom for the path?
also tried sites\all\libraries\galleria\src\themes and sites\all\libraries\galleria\src\themes\

I switch to one of the canned themes it works fine.

Thanks for any help you can toss my way.

aaron’s picture

@thinguy: it needs to have the path including the filename.

Adam S’s picture

I used the script in the galleria demo website as a guide. It looks like this. If your using my custom theme, it could really use some debugging. It would be great if a designer CSS person could spend even just 30 min on it.

    <script>
    Galleria.loadTheme('/media/galleria/src/themes/classic/galleria.classic.js');
    $('#demo').galleria({
        height:400
    });
    </script>
dealancer’s picture

Found the solution. It is very simple:

1) Add alt field in the image field configuration
2) Add alternative text to the image

That's all. Galleria will handle that.

It need to be documented in the README file and project page as well.

dealancer’s picture

Create template in your theme folder for the image field that is shown in the views and paste following code there:

  dpm($output);
  $node = node_load($row->node_node_data_field_galleria_feature_image_ref_nid);
  $out = preg_replace(array('!alt=(?:\'.*?\'|".*?")!', '!title=(?:\'.*?\'|".*?")!'),
                      array('alt="'. strip_tags($node->body) .'"', 'title="'. $node->title .'"'), $output);
  print $out;
Anonymous’s picture

I have struggled for two weeks to get this right. Im at the verge of giving up. Still, no other fields appear. Everything else is fine, except this.

What next?

Please help.

Thanks

Anonymous’s picture

Switched to thumbnailhover.

:)

mmeldrem’s picture

Using sgabe's suggestion here, I've made a custom formatter to add the node link to the 'longdesc' attribute of the image. This causes the image to link to its node. We can modify this image formatter to add additional attributes to the image such as title and caption. By default, Galleria loads the 'alt' attribute as the caption.

$settings = $variables['#display']['settings'];
// can delete the two lines below if you don't want to link the image to its node
$uri = entity_uri($variables['#obj_type'], $variables['#object']);
$link = url($uri['path'], $uri['options']);

$element = array();
foreach ($variables['#items'] as $delta => $item) {

$title = $variables['#object']->title;
$alt = $variables['#object']->body['und'][0]['summary'];

// delete the 'longdesc' => $link declaration below if you don't want to link the image to its node.
  $item['attributes'] = array('longdesc' => $link, 'title' => $title, 'alt' => $alt);
  $element[$delta] = array(
    '#theme' => 'image_formatter',
    '#item' => $item,
  );
}
return $element; 

If you don't have a summary, use ['safe_value'] instead of ['summary'] to use the node's full body field. Of course you can run any php functions on the $alt variable to get the string the length you want before adding to the $item['attributes'] array.

If you choose to link to the image's node, I recommend using this css to change the mouse cursor into the link cursor:

.galleria-image {
	cursor: pointer;
}

Note: I've noticed that if the image already has alt text, this will not override that text. Maybe someone has a workaround for that, but this worked in my situation, and so I wanted to share.

Edit: Sorry for resurrecting an ancient thread, but I couldn't find any clear instructions on how to achieve captions with this module, and this was the solution I found.

mmeldrem’s picture

I just noticed in my above post (#16), that this image formatter doesn't pass the image style(s) that is selected with it in the Views config, yet I need it in order to make the image link to its node. Does anyone know how to make the custom image formatter pass in the image style?

mgifford’s picture

Version: 6.x-1.x-dev » 7.x-3.x-dev
Issue summary: View changes
Issue tags: +longdesc

Also worth considering figure & figcaption along with a move to HTML5.