Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Getting Image paths in a transformation View modes: 
User avatar
Member
Member
lancetek - 9/30/2011 9:55:51 AM
   
Getting Image paths in a transformation
I have a document type that has a Field with an Attribute type of text and a field type of Image Selection. So in the database, a Guid is placed.

What's the Kentico-approved way to get the proper path to the image? A nice path like: "/images/country/uk.gif", not a rubbish path like: "/getattachment/0ba5210e-2637-4843-bf68-29fd5d9b61d4/uk.aspx"

Thanks,
Lance

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 9/30/2011 3:22:13 PM
   
RE:Getting Image paths in a transformation
Hello,

If you saved the image into the media library, you can use the direct path to the file. However, if you have saved the file as a CMS.File or attachment, you need to use the GUID or implement a workaround for that, because CMS.Files and attachments are the same thing. That means that one document can hold multiple attachments, which can have same file names. That means, that we need to have a way how to distinguish the files from each other. For that, GUIDs are used.

Best regards,
Boris Pocatko

User avatar
Member
Member
lancetek - 9/30/2011 11:46:17 PM
   
RE:Getting Image paths in a transformation
Hi,
Our files have just been added as CMS.File to to the filesystem. In the 'Form' tab, the textbox for the Image Field shows the path. Is there an internal function to fetch this? I've been using a custom function that takes the Guid, and tries to find a Node with that NodeGuid identifier... but it's rather long-winded and I assumed that Kentico internally must have a function that takes a node Guid as a parameter and returns the AliasPath.

Lance

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/4/2011 5:28:12 AM
   
RE:Getting Image paths in a transformation
Hi,

in transformation you can use:

GetDocumentUrl(object nodeGuidColumn, object nodeAlias)

as a second parameter you can insert an empty string "".

It will return an URL. So you can pass the output to the method:

GetImageByUrl(object imageUrl )

to generate the image code.

Best regards,
Ivana Tomanickova