I am attempting to write a few ECL's for our use of the CMS and have run into an issue with one of the features.

There is a method in IContentLibraryMultimediaItem:

    public string GetTemplateFragment(IList<ITemplateAttribute> attributes)

My understanding of this method was that the returned string would be the output from the rich text content or at the resolving part of the template building block. However, this is not the case and the output returned is always an "<img>" tag regardless of what I put as a string.

Does anyone know if there's something specific I have to do to get the fragment to render? I've inserted various breakpoints and I never see a break at this method.

I did implement GetDirectLinkToPublished which works fine on the component view page of the ECL item.

Thank you.

  • Notes: Using SDL Web 8, I have Resolve ECL items V2 in my component template.
    – Ryan
    Jan 20, 2017 at 19:28
  • How are you testing this? My understanding is that as long as you have an img tag with a tridion:href attribute, it should call your code. And anything you return will be used as-is. Jan 23, 2017 at 9:37
  • Hi, I'm building the ECL dll and running it directly on my dev server. I've tried an img tag and added tridion:href attribute and it still shows the regular image tag, here's an example: <img src="ecl:26-bc-5273178744001-vid-file" title="Just a few old friends you might run into when visiting Florida" alt="Just a few old friends you might run into when visiting Florida" style="width: 640px; height: 320px;"/> I can set the width and height in the IContentLibraryMultimediaItem but the returned HTML is always this generic <img> tag. My goal is to insert an iframe instead of an img tag.
    – Ryan
    Jan 23, 2017 at 20:09
  • That example doesn't actually have a tridion:href attribute... Jan 24, 2017 at 10:50
  • 1
    That is what is returned every time from RTF box after selecting the ECL item in the image pop up. I cannot manipulate the tag, that is the issue.
    – Ryan
    Jan 24, 2017 at 14:13

3 Answers 3


GetTemplateFragment is ment for use in templates - when actual rendering is happening. What ever you return from this method your template can use in some way to place on page.

What you trying to use it for is "live preview" inside of RTF field.

ECL never calls this method when you place ECL component in to RTF. Instead it place "<img>" and call GetThumbnailImage to represent ECL component in RTF field.

This "<img>" plays role of link to ECL item.

And later when rendering happening, "Resolve ECL items V2" will replace those "<img>" elements with actual content of GetTemplateFragment.
Or if implementation does not use "Resolve ECL items V2" implementer can treat "<img>" elements as needed.

Reason why we can not show "live preview" in RTF field, or multimedia link field, is because it is not supported by CME/XPM.

Just think about this.

If we render piece of strange html in RTF field CME probably will fail to show it anyway. And even if it not. HTML produced by GetTemplateFragment is not what you want to save in to your component. Because then rendering will happen at the time of insertion of ECL component and not in publishing phase. And you want it in publishing phase because only there you can decide what and how should be rendered.

If CME/XPM ever improve RTF viewer we may improve this in future.

But for now your best bet is "Preview" button. That will use templates and proper rendering to show preview.


This is a note from ECL developer:

RTF field is very limited and video player can not be rendered there during editing of component. Instead ECL show full size thumbnail (if "Load Images" button pressed in RTF field).

So in debug you should see call to IContentLibraryContext.GetThumbnailImage Actual transformation to real html fragment happens in template. Your component templates should include "Resolve ECL items V2" building block. So, editors can not preview video player during component editing

But they can use "Preview" functionality


I recently had chance to implement an ECL provider using S3 bucket, See if this helps.

A quick note: GetTemplateFragment() is responsible to return a string format output that does not mean you return a plane string which can not be interpreted by your template.

See the code below:

 public string GetTemplateFragment(IList<ITemplateAttribute> attributes)
        string[] supportedAttributeNames = new[] { "style", "width", "height" };
        string supportedAttributes = attributes.SupportedAttributes(supportedAttributeNames);

        // since photos are already published, so we can provide a template fragment ourselves
        return string.Format("<img src=\"{0}\" alt=\"{1}\" {2}/>", GetDirectLinkToPublished(attributes), Title, supportedAttributes);

Above code is taken from a working example, the return string here is an HTML (RTF) element.

So It does need to return string but a Template fragment of the eclItems. Once your Resolve ECL items V2 TBB gets it in Template It actually creates a base64 version (I am not entirely sure but at least it did in my case) of the fragment..and render it to the page.

Also to answer this :

I've inserted various breakpoints and I never see a break at this method.

  1. Run your code using TridionServiceHost process
  2. Attach your ecl media to a component of a page or something and publish (this will call your methods, if not see next steep)
  3. Open Template Builder, attach your provider code with TcmTemplateDebugHost and debug there.

If it still does not hit your code, then i am not sure what else is going wrong.. Refer the blog link mentioned above and see if you are missing on anything.

Hope this gives you some help!

Your Answer

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

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