6

OK, the heading isn't the best example of english ever, but I hope you get what I mean...

I've run up against the bug in Drupal where it doesn;t check the length of the title value in an image field (http://drupal.org/node/916446) and I was using that field to store the caption for the image which I was displaying in a div underneath the image.

Is there a way to either allow the title field to hold more information, or even better (semantically especially), create an additional field to hold my caption information?

The reason I don't just create a separate field for caption is that I'm allowing multiple images on the image field and from a content management point of view, I wouldn't easily be able to match up the images to their captions.

I'm sure it's something simple like creating a version of the image.field.inc? Has anyone done it or know how to make this happen?

3 Answers 3

2

I believe what you are looking for is the Field Collection module. It allows you to group fields together and repeat the group many times. The following article gives a good description of what the module does: Create Multigroups in Drupal 7 using Field Collections

From the Field Collection project page:

Provides a field-collection field, to which any number of fields can be attached.

A field collection is internally represented as an entity, which is embedded in the host entity. Thus, if desired field collections may be viewed and edited separately too.

1
  • That works. Am a bit nervous about it's maintenance levels given there are 58 open bugs and 123 open issues... Commented Nov 7, 2011 at 2:49
2

The Image Field Caption module for Drupal 7 will add an extra text area on image fields that can be used to enter a caption of plain text or html for each image field's description.

The caption will be rendered below each image on the node display. If you need to customize the display, just take a copy of the image_field_caption.tpl.php file and place it in your theme's directory, then modify the html for your needs:

sites/all/themes/MY_THEME/image_field_caption.tpl.php

In the past I've used the awesome Field Collection module, but it may be a bit heavy when you just need a description/caption on an image field, and that's where the Image Field Caption module comes into play nicely.

0

Revisiting this question after it's been out here for a year, I believe the best possible solution is to not use an image field at all and to use a file field with the Media module instead.

This provides several benefits:

  • Your images become entities - much easier to search, filter, find and use your images.
  • You can add custom fields to your image entity such as a caption as in the original question, or even more specific things like copyright information, photographer credits, tagging and more.
  • For those that don't like tinkering with templates and don't need to do anything too fancy, you also avoid having to create any custom templates because it's all configurable in the UI, just like a content type.

I'd also recommend persevering with Version 2 of the Media module too. It's got a lot going for it. The only exception being high traffic or rock-solid-stable sites. You should probably stick to the version 1 branch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.