We have folder structure like Project folder>>System>>assets>>img and we are trying to publish the multimedia components from the img folder. But when the images are getting published it's appending the TCMID of the component with the title.
If we will publish test.png then we will be able to access this published image like /test_tcm:XXX-YYYY.png.
This is done because to maintain the uniqueness, but if we want to move to another environment then we are getting trouble with this additional tcmID.
We are using below tbb code, any help in pointing out the change or update which can help us in getting the result.
We are using DXA 1.2 Tridion 2013.

Item BinaryItem = package.CreateMultimediaItem(component.Id);
fileName = this.GetPropertyValue(BinaryItem, Item.ItemPropertyFileName);

                        string[] fileArray = null;                                                   
                        // Extract the tcm uri from the item object
                        TcmUri itemUri = new TcmUri(this.GetPropertyValue(BinaryItem, Item.ItemPropertyTcmUri));

                        // See if some template set itself as the applied template on this item
                        string templateURI = this.GetPropertyValue(BinaryItem, Item.ItemPropertyTemplateUri);                            
                        if (String.IsNullOrEmpty(templateURI))
                        TcmUri appliedTemplateUri = new TcmUri(this.GetPropertyValue(BinaryItem, Item.ItemPropertyTemplateUri));                            
                        byte[] data = null;
                        Stream itemStream = BinaryItem.GetAsStream();                            
                            data = new byte[itemStream.Length];
                            itemStream.Read(data, 0, data.Length);

                        if (!BinaryItem.Properties.ContainsKey(Item.ItemPropertyPublishedPath))
                            engine.PublishingContext.RenderedItem.AddBinary(itemStream, fileName, targetSG, appliedTemplateUri, component, mimetype);                               
  • 1
    Can you explain the trouble you would get when moving to another environment? – Rick Pannekoek Nov 25 '16 at 17:24
  • @RickPannekoek, We are using one configurational Component to store the name and value, suppose we have stored the path of one image in there as value. As currently we are getting image name appended by _TCMId after publishing, then we will have to save the image path like /Images/test_tcm:XX-XXXX. Now think we have to move this Configurational component to another environment, then manually we have to append the tcm id to the value from that environment. – SDLBeginner Nov 28 '16 at 6:41
  • Why would you store the published path of a MM Component in configuration? Why not use a Component Link? – Rick Pannekoek Nov 28 '16 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.