Binary links

Binary links point to binary files such as images, PDF documents, Word documents, etc. In the Content Manager, these binary files are contained in Multimedia Components. The default Template Building Block contains code that generates linking code to binary files. Published Pages that refer to this linking code contain scripting used by the Dynamic Link Resolver to ensure that the link is resolved and valid. When a Page is published that contains binary links, code is generated that instructs the Content Distributor to create a link to the binary file with the associated URI, or no link if the binary was never published.

There are various ways to create a binary link (that is, a link to a binary resource) in Content Manager:

  • A content author can set the value of a Component field of type 'Multimedia Link'. The default Templates that SDL Tridion ships with render this as a hyperlink to the published binary resource.
  • In a Component field of type 'Format Area', a content author can click the Hyperlink button, select Component as a link type, and pick a Multimedia Component to link to. The default Templates that SDL Tridion ships with render this as a hyperlink to the published binary resource.
  • If the binary resource is an image, then in a Component field of type 'Format Area', a content author can click the Image button and pick a Multimedia Component that is an image to link to. The default Templates that SDL Tridion ships with render this as an embedded image (img tag).
  • You can write template code that uses the BinaryLink class, and include this code in a Component Template or Page Template.

The following example of using the BinaryLink class shows the code that is generated on a Page before it is viewed and which the Dynamic Link Resolver uses to resolve the binary link:

<%@ Import namespace="Tridion.ContentDelivery.Web.Linking"%>
<%
  BinaryLink binaryLink = null;
%>
<%
  binaryLink = new BinaryLink();
%>
<!-- A binary link -->
<%Response.Write(binaryLink.GetLinkAsString("tcm:115-16684","","binaryAnchor",
"Link for the text","onClick=\"alert('I am a link')\"",true));%>
<!-- end of binary link -->
<%
  binaryLink.Dispose();
%>

Instead of writing an explicit call to BinaryLink.GetLinkAsString, you can also use the <tridion:BinaryLink> Custom Tag or Server Control.