2

I am using below lines of code to add the binary in my CT :

Tridion.ContentManager.Publishing.Rendering.Binary binary = TridionHelper.Engine.PublishingContext.RenderedItem.AddBinary(component);
return binary.Url

I get the result of URL as

“/Images/sample_tcm2-192851.jpg”.

However, the image name is “sample.jpg”, which means the AddBinary method is adding the default variant as TCM- Id of the Image Component (correct me if my understanding is wrong). The image gets published successfully at the above location, hence no problem so far.

But what I have noticed is that in another CT, we are referring the same image component as below:

<img src="@Fields.Image" alt="@Fields.alt" >

This works fine when we publish the page and generates the URL as “/Images/sample.jpg” as expected, but deletes or un-publish the above image i.e. “sample_tcm2-192851.jpg” which results in the broken image in another page.

Am I missing something while using the method AddBinary?

Thanks.

0

Your Answer

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