We have a challenging user requirement that I've been puzzling over and wanted to submit this to the community:

We're using the Media 2 + File Entity modules for managing our site's image library. The Image bundles are fielded with meta data fields e.g. Title, Caption, Source, etc.

So here's the thing-- we need to have a way to override these on a case by case basis but if at all possible without duplicating the File. For example, with stock photography images, we only want to have one image of the lady with a pregnant belly, but it will be used in different ways throughout the site, and we need to be able to give it a different caption in two different places.

We really don't want to have the same image in the library twice with two separate captions. This would drive our editors crazy.

Thanks for any ideas!


There's no easy way to do this for files or images, which are essentially reference fields. There's no native way to do this for any type of reference field in Drupal. For example, you can create a reference field to a node, but override what the node's title is in a certain article when you reference it.

Typically what people recommend is using a Field Collection or a Multifield that consists of an image field + whatever field you want to have as the 'use this value only when this image is used here' stuff.

For captions, I know we added a caption filter specifically in Drupal 8 core, but I cannot find if it got back-ported for Drupal 7. That would be handy to have and use now.


This may be overkill but this is the solution I use to override image fields (stored as file entities and using Media 1) when they are attached to a node.

I use Views to display the image and associated meta data. I have to use a View because I show either a video or an image, depending on which is available. The View will eventually be displayed as a block on a node so I add a Contextual Filter to determine the current page's NID. The View has a Relationship to the file entity and pulls in the meta data fields. The meta data fields are then set to be hidden from display.

The node also has a caption field. The View is configured so that, if there a caption in the node, use that, otherwise, the "No Results" option is set to use the Related file entity's meta data.

I tie this together with Display Suite to create a Block Field which pulls in the View and makes it available to the node's Manage Display tab. And it is critical to configure the View's caching options to avoid slowing down the site.

Your Answer

