Skip to content

Instantly share code, notes, and snippets.

@SteveDesmond-ca
Last active October 27, 2015 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveDesmond-ca/95a15721ddddf8fd010f to your computer and use it in GitHub Desktop.
Save SteveDesmond-ca/95a15721ddddf8fd010f to your computer and use it in GitHub Desktop.
server-side responsive images
public FilePathResult Image(int id, int x, int y)
{
var image = db.Images.First(i => i.ID == id);
var newPath = image.GetFile(imagePath, new Size(x, y));
return File(newPath, "image/jpeg");
}
public string GetFile(string imageDirectory, Size size)
=> ImageRetriever.GetImage(imageDirectory, Name, size)
?? ImageCreator.CreateImage(imageDirectory, Name, size);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment