101 - Launchpad (Rockumentation)

Referencing Files and Images

There are two ways to fetch (reference) files and images from storage: using GetFile.ashx or GetImage.ashx while passing either the ID or GUID as shown in this example:

# Getting a file
GetFile.ashx?guid=735A97A3-7A9A-4D3F-BE86-B3874E85E141

# Getting an image
GetImage.ashx?id=3

The final reference might look like this <img src="~/GetImage.ashx?id=3" alt='logo'> in your block.

Using the GetFile.ashx handler to fetch large files is fast and efficient because the file is streamed from the storage asynchronously and is not loaded into memory to do so.

Using the GetImage.ashx handler gives you additional features such as resizing, rotating, as well as it will cache those transformations. To rotate an image simply pass rotate with the number of degrees. To resize an image, simply pass height and width parameters or maxheight and maxwidth. Using the latter will maintain the aspect ratio while using the former will force the image into the provided dimensions.

# Rotate 45 degrees
GetImage.ashx?guid=735A97A3-7A9A-4D3F-BE86-B3874E85E141&rotate=45

# Resize forcing into 300 x 200
GetImage.ashx?id=3&width=300&height=200

Note

Image resizing and rotation are provided by the ImageResizer project (v4). Their complete reference can be found on the ImageResizer project website.  

QR Codes

There is also a GetQRCode.ashx handler to dynamically generate QR codes that can be embedded in web pages, printed on materials, etc. The QR codes are generated based on the text or URL you provide through the query string parameters.

To use this handler, you need to provide the data parameter in the query string, which will be encoded into the QR code.

The following parameters are supported by this handler:

  • data - The text or URL to encode in the QR code. This is a required parameter.
  • outputType - The image type to generate; either 
  • pixelsPerModule - The pixel size each b/w module is drawn. (Default is 20)
  • foreground (v17) - The color hex value to use for the foreground (b) color. Transparency is supported using RGBA values. (Default is #000000)
  • background (v17) - The color hex value to use for the background (w) color. Transparency is supported using RGBA values. (Default is #FFFFFF)
/GetQRCode.ashx?data=ABC&background=%23FF5C0077

The example above generates a QR code that encodes the text ABC to output as a PNG with a semi-transparent orange background color.