3
votes

In SDL Tridion, Dreamweaver template, I have to set a relative path to my image in Page Template.

Tridion produces output as below when I do have code like this in DWT.

DWT Markup

<img src="@@Field@@"/>

Template Renders

<img src="image.jpg"/>

However when I add a relative path like this, the template returns tcmid

DWT Markup

<img src="Folder/img/@@Field@@"  type="text/css" rel="stylesheet"/

Template Renders

<img src="tcm:8-674"/>

And this causes images not being presented properly in website. I tried with Tridion type: multimedia etc, but nothing has worked so far.

Has anyone seen a similar issue before?

3
Check my answer below. Can you provide more information about what you are trying to accomplish? - Mihai Cădariu
Can you confirm you are using the Resolve Linking and Publish Binaries in HTML TBBs in addition to your DWT template? Or possible the Default Finish Action TBB? - Chris Summers
Yes, I'm using the default finish action TBB. - krishnakumar k

3 Answers

3
votes

The behaviour you experience is that Tridion (the Dreamweaver mediator) will interpret your src image attribute as WebDAV path of an item in the Content Manager. So if it finds a Multimedia Component under Folder/img/@@Field@@, it will replace your path with the TCMURI of that Multimedia Component. That's expected behaviour.

However, I don't think that's what you are trying to do (it's not clear from your question). Is your image in Tridion as a Multimedia Component? Are you trying to show this image? Then you should use Multimedia Links (i.e. links to a Multimedia Component) in your DWT: <img src="@@Compoennt.Fields.link_to_mmc@@"/>, where field link_to_mmc is a Multimedia Link field defined in your Schema. Use then also the 'Resolve Links' Default TBB to convert the TCMURI into a relative image path.

If you are linking to an external image, then you need to specify the URL of that image in your DWT template. Something like this <img src="@@Component.Fields.external_url@@"/>, where external_url is a Text field in your Schema and it contains the actual URL of the external image you want to show.

3
votes

It seems like you are almost there, only when you add the string as a relative path, the default TBBs don't recognize the uri held in the SRC attribute anymore. If you are trying to publish the binary to a different location, you will need to bind it to a different Structure Group, alternatively try changing the multimedia URL on your publication. that way the images will be published (and resolved) to you sub directory.

3
votes

If your imagefields field is a link to a Multimedia Component, then all you need is <img src="@@Field@@"/>. With that Tridion will (in this order):

  1. replace the @@Field@@ with the TCM URI of the image (e.g. tcm:6-874) when it executes the DWT
  2. put the image item into the package as an implicit step after executing the DWT
  3. publish the images (as one of the steps in the Default Finish Actions)
  4. replace the TCM URI (tcm:6-874) with the path of the published image

Since you'll probably have custom TBBs between the DWT and the Default Finish Actions, you could use those to modify the image item and influence what gets published (and where, using item properties).

If you've set up your Tridion installation correctly, you'll typically store the base path to the images in the Publication properties and then step 3 just puts the the image in there and step 4 puts the full path (including what you specified in the Publication properties) into the HTML.

If you want more control over the relative path, the Publish Binaries in Package and Default Finish Actions TBBs have a parameter that allows you to specify to which Structure Group the images will be published. That way you can have different templates output their images to different Structure Groups/directories on disk.

For the ultimate in control you can also decide to publish the binaries yourself. In that case have a look at the source of the Publish Binaries in Package TBB (available from the forum on SDL Tridion World), modify it to suit your needs and replace the one in Default Finish Actions with your modified version.