5

I want to Publish an image in a Multimedia Component in SDL Tridion 2013. It should preserve the folder structure as it it was created.

If I have created the Multimedia Component in a Folder say Images/abc/xyz/my image, after publishing it should be Images/abc/xyz/my image on the web server also.

1
  • 1
    You might want to show what you've done and where you're stuck exactly, along with any research you've already done.
    – Drew Khoury
    Commented Feb 27, 2014 at 6:49

3 Answers 3

13

A while back I've written a TBB that does exactly what you want, including checking if a Structure Group exists that mirrors the path of the Folder (based on relative WebDav paths).

Here is the link: http://www.tridiondeveloper.com/publish-an-image-to-a-structure-group-mirroring-folder

0
6

In order to achieve this I suggest reading the API manual, and look for the AddBinary() method. This will allow you to publish the file with a specific filename, and bind it to a Structure Group. You will need to make Structure Groups to match your Folder structure in order to fully achieve what you want.

4

As Chris mentioned, the addBinary method (from the namespace: Tridion.ContentManager.Publishing.Rendering.RenderedItem) is what you need, here's the options available:

  • AddBinary(Component); AddBinary(Component, String);
  • AddBinary(Component, StructureGroup);
  • AddBinary(Component,StructureGroup, String);
  • AddBinary(Stream, String, String, Component,String);
  • AddBinary(Stream, String, StructureGroup, String, Component,String);

If you wish to publish to a specific location, you can supply a StructureGroup parameter to addBinary, the image will then be published into the directory related to the particular StructureGroup.

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.