5

I have a multimedia field in metadata on a Keyword. If I publish the taxonomy to the broker, I noticed the value stored in CUSTOM_META appears to set the publication id of the image component to "0" - tcm:35-20912 is stored as tcm:0-20912 - I assume this is correct behaviour?

I know simply publishing the taxonomy wont get this multimedia physically published but in our case it is used on a component that is publishing binary to the file system.

We have logic that is based around the published taxonomy and I can see in the BINARYVARIANTS table a reference to the file - is there an API that gives me access to the URL field? I thought GetBinary might do given I know the pub id and I know the multimedia component id but the BinaryData type it returns doesn'y have URL in it?

Cheers

1 Answer 1

4

You can use

BinaryMetaFactory.BinaryMeta GetMeta(string tcmId);

Here is a snippet, adapted from the offline Docs BinaryMetaFactory:

//create a new BinaryMetaFactory instance:
BinaryMetaFactory binaryMetaFactory = new BinaryMetaFactory();
//find the metadata for the specified binary
BinaryMeta binaryMeta = binaryMetaFactory.GetMeta("tcm:1-123");
//print the path to the output stream:
if(binaryMeta!=null) {
    Response.Write("Path of the binary: " + binaryMeta.UrlPath);
}
//Dispose the BinaryMetaFactory
binaryMetaFactory.Dispose();

You also mention:

"but in our case it is used on a component that is publishing binary to the file system."

This means you have a Component Template publishing the MM component as a Component Presentation. In your CT, you can either call the engine.AddBinary() function which returns the URL to the binary resource which you can render in the Output of the CT, e.g. <img src="/path-that-add-binary-method-returns" />, or your Default Finish Actions' Publish Binaries in Package TBB resolved the binary TCM IDs to URLs to in your Output for you.

So what you can do is retrieve the Component Presentation by the MM Component ID using the ComponentPresentationFactory.GetComponentPresentation(componentId, templateId) method.

1
  • Thanks Nickoli = is that actually GetMeta? There doesn't appear to be a GetBinaryMeta (although its shown in the docs!).
    – Neil
    Jul 11, 2013 at 15:16

Your Answer

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

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