Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Access transformation functions via code View modes: 
User avatar
Member
Member
leem - 8/4/2009 9:19:06 AM
   
Access transformation functions via code
Hi,

Can/How would you reference the method GetImage used on transformations (/index.html?newedit_transformation_methods.htm) within code?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 8/5/2009 2:10:20 AM
   
RE:Access transformation functions via code
Hello.

What version do you use, please? These methods are available in CMSAbstractTransformation class. So, e.g. in version 4.0, full path to GetImage() method is: CMS.Controls.CMSAbstractTransformation.GetImage()

Best Regards,
Radek Macalik
Support Engineer

User avatar
Member
Member
leem - 8/5/2009 7:14:46 AM
   
RE:Access transformation functions via code
Hi,

I'm using v4, I tried your method above and got the below error, also I want to get the image url not the html markup for the image

System.NullReferenceException: Object reference not set to an instance of an object.
at CMS.Controls.CMSAbstractTransformation.get_DataItem()
at CMS.Controls.CMSAbstractTransformation.get_DataRowView()
at CMS.Controls.CMSAbstractTransformation.Eval(String columnName)
at CMS.Controls.CMSAbstractTransformation.GetFileUrl(Object attachmentGuidColumn)
at CMS.Controls.CMSAbstractTransformation.GetImage(Object attachmentGuidColumn, Object imageUrl, Object maxSideSize, Object width, Object height, Object alt)
at CMS.Controls.CMSAbstractTransformation.GetImage(Object attachmentGuidColumn)

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 8/10/2009 7:01:39 AM
   
RE:Access transformation functions via code
Hello,

Could you please use following sample code to get URL of file/image (attachmentGuid is guid stored in field of FileUpload type):

this.ResolveUrl(CMS.FileManager.AttachmentManager.GetAttachmentUrl(attachmentGuid, nodeAlias));

Best Regards,

Martin Dobsicek