How do I access the Binary Metadata using DD4T?

Update: My Multimedia Component is published to the filesystem. I believe that with DD4T I need to publish the MM Component to the Database to be able to retrieve it using the DD4T methods. I was mislead by the fact that some of the methods to get the Multimedia Component were working - but this makes sense, because those methods are from ContentDelivery and not DD4T. I plan to change the MM Component to publish to the database and then retry.

Currently I use this code but it does not get me the Metafields:

BinaryMetaFactory bmf = new BinaryMetaFactory();
BinaryMeta binaryMeta = bmf.GetMeta("tcm:8-148");

enter image description here

  • Do you mean Custom Meta? You should be able to use: new DD4T.Factories.ComponentFactory().GetComponent("tcm:8-148").MetadataFields. At least thats how I always do it, although I use a Singleton for instantiating the ComponentFactory. Alternatively you can of course also use the normal Tridion API.
    – Raimond
    Nov 28, 2013 at 17:28
  • I get a ComponentNotFound Exception when Trying to use GetComponent. Also, I do see the Multimedia Component XML in the Page Preview.
    – robrtc
    Nov 28, 2013 at 17:36
  • Is the component / binary meta appearing in the Broker DB at all?
    – Raimond
    Nov 28, 2013 at 17:38
  • Yes, it's there and when I do this I get the object, BinaryMeta binaryMeta = binaryMetaFactory.GetMeta("tcm:8-150");
    – robrtc
    Nov 28, 2013 at 17:54

1 Answer 1


You are mixing two things: one is the Tridion API where you can access the binary (the file), and the second is the DD4T API where you can access the metadata on it. You mentioned you have the metadata in your page XML, which means you can get it through DD4T.

Option 1 is to use the DD4T page object or its ComponentPresentations objects it is used on; beneath the scenes a DD4T multimedia link field is a component link field so you can actually get the metadata fields off one.

Option 2 is to apply a dynamic component template to your multimedia and ensure they are dynamically published. In that case, you can actually use the DD4t ComponentFactory API like that.

Good luck,


  • Trying option 1 first - From the Component I can access the MM Comp and Metadata fields. This is the good news. But, how would I do this from the Page level? The XML for the Page in DD4T does contain the MM Comp Metadata Info - but how to get to it?
    – robrtc
    Nov 29, 2013 at 11:19
  • Option 2 works very easily: string mmCompUri = "tcm:8-148"; ComponentFactory cf = new ComponentFactory(); var mmComp = cf.GetComponent(mmCompUri); string security = mmComp.MetadataFields["Security"].Value.ToString();
    – robrtc
    Nov 29, 2013 at 11:42
  • Option 3: I understand I would also need to publish the MM Comp to the Broker, as in Option 2?
    – robrtc
    Nov 29, 2013 at 11:42
  • Option 1: it depends on what you're trying to do if this makes sense or not; if you're rending a component view in razor this is easy. If you're doing something based on a broker query, it probably isn't. Nov 29, 2013 at 11:53
  • Option 3: fair point; i just realized this only works for a DCP or a normal CP, not for a linked component. I'll edit it from the answer. Nov 29, 2013 at 11:55

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.