Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewriting binary links to use CDN

CDN integration seems to be a hot topic among Tridion crowd. But, somehow, available discussions mainly revolve around pushing content to/fro CDN. What i'm specifically interested is:

What will be the proper way of modifying/prefixing inline images outbound links to use CDN?

The simplest way to go would be to create some post-processing TBB, operating on Output item, and place it inside 'Default Finish Actions'. Though, doing this on CD side would seem to be more correct, ain't it so?

EDIT

Consider fancier case: what if not only I want to modify image paths, but wrap the whole image links into ASP.Net controls. Where do I do this?

EDIT 2

So far, implemented tag to ASP.Net control replacement via TBB. Went smooth, only needed to keep an eye on the following subtle matters:

  • Consider CSS inline styles (i.e.: background-image: url(..))
  • New TBB needs to be placed after any link-manipulating logic (e.g.: Extract Binaries from Html, Publish Bnaries in Package, Link Resolver)
  • The quickest and most robust implementation is probably with a simple string replacements (in contrast to regexp's or XML parsing)
  • To keep standard "Preview" logic intact, some condition is necessary to trigger the logic
like image 833
esteewhy Avatar asked Dec 16 '12 09:12

esteewhy


1 Answers

If you decide to go with ASP.NET controls for your CDN-hosted images, you may consider these phases/steps:

  1. write a TCDL tag (e.g. <tcdl:image id="..." path="...") on CM during rendering
  2. write a TCDL TagHandler implementation that transforms the TCDL into an ASP.NET include during deployment
  3. write the ASCX control to do the CDN lookup proper when the visitor requests the page

I'm not sure if both step 2 and 3 are needed. You might also simply write the CDN path during the deployment phase (step 2 above).

At the same time I'd expect you to upload (updated) images to the CDN using a deployer extension, so that it also happens during phase 2.

like image 50
Frank van Puffelen Avatar answered Oct 09 '22 06:10

Frank van Puffelen