Sure..
the idea is that instead of using an HttpHandler to generate and cache
thumbnails, we do so using an ActionResult.
Things currently look like the following :
<code>
public class ThumbnailResult : ActionResult
{
public ThumbnailResult()
{
}
public string Original { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Quality { get; set; }
public string CacheDirectory { get; set; }
public string MimeType { get; set; }
public string FileNotFoundImage { get; set; }
public TimeSpan? ResponseCacheTimeout { get; set; }
......
</code>
A thumnail of Original is generated based on the given Width and
Height. If CacheDirectory is specified, the thumbnail is cached (the
file name is generated from Original, Width, Height and Quality). If
Original is not found, FileNotFoundImage is sized and sent to the
browser.
ResponseCacheTimeout determines browser cache timeouts. If set, we
generate ETags (based on the specified parameters), and check against
those, as well as comparing if-modified-since against the LastWriteUTC
timestamp of the original file.
I havent done HtmlHelperExtensions yet, thought i dont think they're
necessary, since were talking about an ActionResult which can be
returned by any controller, so any extension method would be project
specific, or handled by Html.ActionLink<T>. My initial use case is
something like this ...
// MemberController
public ActionResult MiniThumbnail(int userId)
{
User user = userRepository.Get(userId);
if (user == null)
return new NotFoundResult();
String profilePhoto = user.ProfileImage;
return GetThumbnailResult(profilePhoto, ImagePresets.MiniPhoto);
}
public ActionResult ProfilePhoto(int userId)
{
User user = userRepository.Get(userId);
if (user == null)
return new NotFoundResult();
String profilePhoto = user.ProfileImage;
return GetThumbnailResult(profilePhoto,
ImagePresets.ProfilePhoto);
}
protected ActionResult GetThumbnailResult(String filename, ImagePreset
preset) {
ThumbnailResult result = new ThumbnailResult(){
Original = filename,
Width = preset.Width,
Height = preset.Height, // either height or width can be
left out
Quality = preset.Quality,
FileNotFoundImage = config.NoPhotoFilename,
CacheDirectory = config.ThumbnailCacheDirectory
};
return result;
}
At this point, we can probably create a simple Html.Image extension
// Profile.aspx
<div id="user-photo">
<%=Html.Image<MemberController>(c=>c.ProfilePhoto(Model.Id),
"Profile Photo") %>
</div>
On Jun 12, 9:20 pm, Eric Hexter <
eric.hex...@gmail.com> wrote:
> Can you provide some more details around how this works or what the usage of
> this looks like?
>
> Eric Hexter
>
> Principal Consultant
> Headspring Systems |
www.HeadspringSystems.com
> email: ehex...@HeadspringSystems.com