/// <summary> /// Builds the relative url for the specified image. /// </summary> public string BuildUrl(string virtualPath, int?width, int?height) { if (string.IsNullOrWhiteSpace(virtualPath)) { throw new ArgumentException(nameof(ImageStorageProviderLocalWebsite), new ArgumentException(nameof(BuildUrl), new ArgumentNullException(nameof(virtualPath)))); } var builder = new ImageUrlBuilder(); if (width.HasValue && height.HasValue) { builder.Resize(i => i.Dimensions(width.Value, height.Value)); } else if (width.HasValue || height.HasValue) { if (width.HasValue) { builder.Resize(i => i.Width(width.Value)); } if (height.HasValue) { builder.Resize(i => i.Height(height.Value)); } } else { builder.Cache(CacheOptions.Always); } builder.Resize(i => i.Crop()); return(builder.BuildUrl(virtualPath)); }
public void Cache() { builder.Cache(CacheOptions.Always).BuildUrl("image.jpg") .ShouldEqual("image.jpg?cache=always"); }