Image control

OpenWaves.Web.Controls.Image is a web control that in many ways mimics the behavior of asp:Image control. The key difference is that it can use IWebImageTransformationService obtained from ServiceLocator to apply selected transformation to an image before rendering. Default implementation of IWebImageTransformationService for performance reasons will transform/scale the image only on first request and store it for future use (see Image Transformations for Web).

Usage example

The following markup will render img tag with src attribute pointing to a version of "foo.jpg" scaled to fill 80x80 rectangle.

<%@ Register Assembly="OpenWaves.Web" Namespace="OpenWaves.Web.Controls" TagPrefix="ow" %>
...
<ow:Image runat="server" ImageUrl="/Images/foo.jpg" Transformation="ScaleToFill" Width="80" Height="80" />       

Properties

ImageUrl - url to an orginal image to be transformed. The url must be resolvable by currently registered IWebImageTransformationService (see: Image Transformations for Web).

Transformation - one of ImageTransformationType enumeration members (default is None):

 public enum ImageTransformationType
 {
     None,
     CentralCrop,
     Stretch,
     ScaleToFit,
     ScaleDownToFit,
     ScaleToFill
 }

Width, Height - target dimensions of the given transformation (both required if Transformation != None)

HideIfEmpty - when set to false (default), and ImageUrl is null or empty, Image control will render img tag without src attribute (just like asp:Image). When set to true, it will not render img tag if ImageUrl is null or empty.

FallbackImageUrl - image url to be used when ImageUrl is null or empty and HideIfEmpty == false. Often used to show generic picture placeholder image when a picture is not provided by editors.

Last edited Sep 9, 2011 at 2:44 PM by mgrzyb, version 2

Comments

No comments yet.