hello maintainers of the picture module-
and thanks for your brilliant work.

here is just a small patch i made, to add captions from the image title field, if its used.

in picture.module [7.x-1.x-dev] change this-

    $output[] = '<noscript>' . theme('image_style', $variables) . '</noscript>';
    $output[] = '</span>';
    return implode("\n", $output);

to this-

    $output[] = '<noscript>' . theme('image_style', $variables) . '</noscript>';
    $output[] = '</span>';

    if (!empty($variables['title'])) {
      $output[] = '<span class="image-caption-title">' . $variables['title'] . '</span>';
    }

    return implode("\n", $output);

of course you can use a div instead of a span, for the caption element. you can also use css to selectively toggle the display of captions on/off easily thru the theme- for various content types, or entity view modes, or teasers- or anything you can style with css.

for example-

.image-caption-title {
  display: none;
}

.view-mode-full .image-caption-title {
  display: block;
}

.view-mode-full .field-type-entityreference .image-caption-title {
  display: none;
}

.view-mode-full .view .image-caption-title {
  display: none;
}

i found this an easy way both to add or not add captions, for any any given image- which always gets an alt field filled out- but then if you add the title field too, the caption will be displayed nicely. the additional css gives fine-grained control however you might want.

Comments

jboeger’s picture

Thanks Basic Magic!

attiks’s picture

Status: Active » Needs work

Problem is that not everybody is going to want this, so we need a way to control it

Andru’s picture

Hi thanks for this. As for controlling it Image Field Caption module lets you add captions to image fields, and configure per content type. To use with Picture would mean pulling in the caption values from the module's own DB table, called image_field_caption.

I'm also using display:none to hide titles where I don't want them, but a better solution would be preferable.

attiks’s picture

I created an issue to add support for it, see #2313081: Add support for picture module

attiks’s picture

Status: Needs work » Closed (duplicate)
fallenturtle’s picture

Would there be a way to do this with a theme override so I don't have to patch the module? I don't want to have this whole thing break if my client updates the module.