Image resizer HTML Helper

You can use ResizedImage helper to include resized image into your views.
This helper allows to avoid requests to file handler and any redirects: it just puts link to file in file folder.
Helpers located in Amba.ImagePowerTools.HtmlHelpers namespace.

Helper call:
@Html.ResizedImage(image.FilePath, width:250, height:190, htmlAttributes: new {alt = "Lolcats"}) 

result:
<img alt="Lolcats" style="width:250px;height:190px;" src="/Media/Amba.ImageCache/Default/img/lolcats/fatcat-6DEBDBE03B0671AC98D6E771A48503E5.jpg">

Also you can use helper to get resized image url:
@Url.ResizedImageUrl(image.FilePath, width:250, height:190)

returns:
/Media/Amba.ImageCache/Default/img/lolcats/fatcat-6DEBDBE03B0671AC98D6E771A48503E5.jpg


Helpers allows to use ImageResizing commands (chcek reference: http://imageresizing.net/docs/basics) by settings parameter.
@Html.ResizedImage(image.FilePath, width:250, height:190, settings: "mode=crop&tograyscale=1" htmlAttributes: new {alt = "Lolcats"}) 


tograyscale - is custom grayscale filter included to Image Power Tools module.



Last edited Apr 12, 2013 at 11:56 AM by musukvl, version 8

Comments

No comments yet.