Documentation > CMS Template API Library > Img > Load(AssetPath)

Load

Loads an image using the specified CMS assetPath.

public CrownPeak.CMSAPI.Img Load(AssetPath)


Returns

The Img object.

Parameters

NameDescriptionType
assetPath The assetPath: Could be an assetPath to an asset path or to an attachment. CrownPeak.CMSAPI.AssetPath

Code Example

C#

Sample:
 
            
            
            // Load an image from an uploaded asset (no template)
            Asset photo = Asset.Load("/Assets/Uploaded/Photos/myphoto.jpg");
            if (photo.IsLoaded)
            {
              Img img = Img.Load(photo.AssetPath);
              if (!img.HasError)
              {
                Out.WriteLine("<img src=\"{0}\" width=\"{1}\" height=\"{2}\" />", photo.GetLink(), img.Width, img.Height);
              }
              else
              {
                Out.WriteLine("Loading image failed. Error: {0}", img.ErrorMessage);
              }
            }
            
            
            

Connect with Crownpeak