ImageResizer
3.4.0
|
A set of utility methods for manipulating virtual paths More...
Public Member Functions | |
delegate string | VariableResolverCallback (string variableName) |
A method that resolves variable names to values for the ResolveVariablesInPath method More... | |
Static Public Member Functions | |
static string | SetExtension (string path, string newExtension) |
Should be called SetFullExtension. Sets the file extension of the specified path to the specified value, returning the result. If an extension has multiple parts, it will replace all of them. Leading dots will be stripped from 'newExtension' and re-addd as required. The querystring and fragment is maintained as-is. Semicolon syntax not supported. More... | |
static string | RemoveFullExtension (string path) |
Removes all extension segments from the filename or URL, leaving the querystring intact. I.e, image.jpg.bmp.tiff?hi would be image?hi The querystring and fragment is maintained as-is. Semicolon syntax not supported. More... | |
static string | RemoveExtension (string path) |
Removes the extension from the filename or URL, leaving the querystring intact, where the extension is only the last extension segment. I.e, image.jpg.bmp.tiff?hi would be image.jpg.bmp?hi after this call. The querystring and fragment is maintained as-is. Semicolon syntax not supported. More... | |
static string | AddExtension (string path, string newExtension) |
Adds the specified extension to path, returning the result. Multiple calls will result in "path.ext.ext.ext.ext". The querystring and fragment is maintained as-is. Semicolon syntax not supported. More... | |
static string | GetFullExtension (string path) |
Will return the full extension, like ".jpg.ashx", not just the last bit. Excludes extensions containing spaces or slashes. The querystring and fragment is ignored. Semicolon syntax not supported. More... | |
static string | GetExtension (string path) |
Grabs the last segment of the filename extension. Returns an empty string if there is no extension, or if the extension contains a space. Includes the leading '.' The querystring and fragment is ignored. Semicolon syntax not supported. More... | |
static string | ResolveAppRelative (string virtualPath) |
Resolves app-relative paths to virtual paths. Does nothing with virtual or relative paths. More... | |
static string | ResolveAppRelativeAssumeAppRelative (string virtualPath) |
Turns relative paths into domain-relative paths. Turns app-relative paths into domain relative paths. More... | |
static string | AddQueryString (string virtualPath, string querystring) |
Joins the path and querystring. If the path already contains a querystring, they are 'append joined' with the correct character. Fragment is maintained as-is. Does not support the semicolon syntax. More... | |
static string | RemoveQueryString (string path) |
Removes the query string from the specifed path. If the path is only a querystring, an empty string is returned. Does not support the semicolon syntax. Fragment is maintained as-is. More... | |
static string | MergeOverwriteQueryString (string path, NameValueCollection newQuerystring) |
Overwrites exisisting querystring values in 'path' with the values in 'newQuerystring'. Does not support the semicolon syntax. More... | |
static string | MergeQueryString (string path, NameValueCollection newQuerystring) |
Adds the querystring values in 'newQuerystring' to the querystring in Path, but does not overwrite values. Does not support the semicolon syntax. More... | |
static string | BuildQueryString (NameValueCollection QueryString) |
Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded as they should be. More... | |
static string | BuildQueryString (NameValueCollection QueryString, bool urlEncode) |
Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded if urlEncode=true. More... | |
static string | BuildSemicolonQueryString (NameValueCollection QueryString, bool urlEncode) |
Returns a string querystring in the form ";key=value;key=value". Keys and values are UrlEncoded if urlEncode=true. More... | |
static string | BuildQueryString (NameValueCollection QueryString, bool urlEncode, bool skipNullValues=true, char firstSeparator= '?', char laterSeparators= '&', char equals= '=') |
Build a customized querystring from a NameValueCollection More... | |
static NameValueCollection | ParseQueryStringFriendly (string path) |
Like ParseQueryString, but permits the leading '?' to be omitted. Does not support the semicolon syntax. More... | |
static NameValueCollection | ParseQueryStringFriendlyAllowSemicolons (string path) |
Like ParseQueryString, but permits the leading '?' to be omitted, and semicolons can be substituted for '&' More... | |
static NameValueCollection | ParseQueryString (string path) |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values. More... | |
static NameValueCollection | ParseQueryString (string path, bool allowSemicolons) |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values. Does not enforce correct syntax, I.E. '?key=value?key2=value2' is allowed. However, '&key=value?key2=value' will only get key2 parsed. When allowSemicolons is true, semicolon paths like ';key=value;key2=value2' are allowed, as are hybrid paths: ';key=value?key2=value2&key3=value3'. More... | |
static NameValueCollection | ParseQueryString (string path, bool allowSemicolons, out string beforeQuery, out string fragment) |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values. Does not enforce correct syntax, I.E. '?key=value?key2=value2' is allowed. However, '&key=value?key2=value' will only get key2 parsed. When allowSemicolons is true, semicolon paths like ';key=value;key2=value2' are allowed, as are hybrid paths: ';key=value?key2=value2&key3=value3'. More... | |
static NameValueCollection | ParseQueryOnly (string query, bool allowSemicolons=true, bool urlDecode=true) |
Parses a querystring into a name/value collection. The given string cannot include path or fragment information - it must be just the querystring. More... | |
static string | ToBase64U (byte[] data) |
Converts aribtrary bytes to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /) More... | |
static byte[] | FromBase64UToBytes (string data) |
Converts a URL-safe version of base64 to a byte array. (no = padding, with - instead of + and _ instead of /) More... | |
static string | ToBase64U (string data) |
Converts aribtrary strings to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /) More... | |
static string | FromBase64UToString (string data) |
Converts a URL-safe version of base64 to a string. 64U is (no = padding, with - instead of + and _ instead of /) More... | |
static string | MapPathIfAppRelative (string path) |
Returns the physcial mapped path for the specified virtual path if it starts with ~, otherwise retuns the original path. More... | |
static string | GenerateImageUrl (string path, NameValueCollection query) |
Generates a resized image url for the specified physical or virtual path. Not CloudFront compatible. Does not support remote URLs, use RemoteReader for that. If you're running in IIS classic, add ".ashx" to the 'path' parameter. More... | |
static string | GuessVirtualPath (string path) |
Attempts to guess the virtual path from physical path. Will be thrwarted if the path is mapped as a virtual folder inside the application. If the path is a non-physical path, it will be returned as is. Returns null if the physical path isn't a subfolder of the application's physical path. More... | |
static string | ResolveVariablesInPath (string pathWithVars, VariableResolverCallback resolver) |
Replaces variables in paths with their values. Ex. ~/uploads/thumbs/<guid>.<ext>. Standard variables are <ext> (the default extension for the final file type), <guid>, a randomly generated GUID, <filename>, the original filename without it's extension, <path>, the original path and filename without extension, <settings.width>, (any specified settings value except preset), <width> (final width), and <height> (final height). More... | |
static string | RemoveNonMatchingChars (string text, string chars) |
Allows a string to be filtered using the specified whitelisting expression (regex style). More... | |
static NameValueCollection | FilterQueryString (ResizeSettings query, params string[] keepKeys) |
Returns a new collection containing only the specified keys from the old one More... | |
Properties | |
static string | AppVirtualPath [get] |
Returns HostingEnvironment.ApplicationVirtualPath or "/", if asp.net is not running More... | |
static string | AppPhysicalPath [get] |
If not running in ASP.NET, returns the folder containing the DLL. More... | |
A set of utility methods for manipulating virtual paths
Definition at line 17 of file PathUtils.cs.
|
inlinestatic |
Adds the specified extension to path, returning the result. Multiple calls will result in "path.ext.ext.ext.ext". The querystring and fragment is maintained as-is. Semicolon syntax not supported.
path | |
newExtension |
Definition at line 104 of file PathUtils.cs.
|
inlinestatic |
Joins the path and querystring. If the path already contains a querystring, they are 'append joined' with the correct character. Fragment is maintained as-is. Does not support the semicolon syntax.
virtualPath | |
querystring |
Definition at line 178 of file PathUtils.cs.
|
inlinestatic |
Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded as they should be.
QueryString |
Definition at line 249 of file PathUtils.cs.
|
inlinestatic |
Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded if urlEncode=true.
QueryString | |
urlEncode |
Definition at line 259 of file PathUtils.cs.
|
inlinestatic |
Build a customized querystring from a NameValueCollection
QueryString | |
urlEncode | True to URL encode all values |
skipNullValues | If true, null-valued keys will be skipped |
firstSeparator | Usually ? or ; |
laterSeparators | Usually & or ; |
equals | Always = |
Definition at line 284 of file PathUtils.cs.
|
inlinestatic |
Returns a string querystring in the form ";key=value;key=value". Keys and values are UrlEncoded if urlEncode=true.
QueryString | |
urlEncode |
Definition at line 271 of file PathUtils.cs.
|
inlinestatic |
Returns a new collection containing only the specified keys from the old one
query | |
keepKeys |
Definition at line 583 of file PathUtils.cs.
|
inlinestatic |
Converts a URL-safe version of base64 to a byte array. (no = padding, with - instead of + and _ instead of /)
data |
Definition at line 445 of file PathUtils.cs.
|
inlinestatic |
Converts a URL-safe version of base64 to a string. 64U is (no = padding, with - instead of + and _ instead of /)
data |
Definition at line 462 of file PathUtils.cs.
|
inlinestatic |
Generates a resized image url for the specified physical or virtual path. Not CloudFront compatible. Does not support remote URLs, use RemoteReader for that. If you're running in IIS classic, add ".ashx" to the 'path' parameter.
path | |
query |
Definition at line 483 of file PathUtils.cs.
|
inlinestatic |
Grabs the last segment of the filename extension. Returns an empty string if there is no extension, or if the extension contains a space. Includes the leading '.' The querystring and fragment is ignored. Semicolon syntax not supported.
path |
Definition at line 134 of file PathUtils.cs.
|
inlinestatic |
Will return the full extension, like ".jpg.ashx", not just the last bit. Excludes extensions containing spaces or slashes. The querystring and fragment is ignored. Semicolon syntax not supported.
path |
Definition at line 116 of file PathUtils.cs.
|
inlinestatic |
Attempts to guess the virtual path from physical path. Will be thrwarted if the path is mapped as a virtual folder inside the application. If the path is a non-physical path, it will be returned as is. Returns null if the physical path isn't a subfolder of the application's physical path.
path |
Definition at line 494 of file PathUtils.cs.
|
inlinestatic |
Returns the physcial mapped path for the specified virtual path if it starts with ~, otherwise retuns the original path.
path |
Definition at line 470 of file PathUtils.cs.
|
inlinestatic |
Overwrites exisisting querystring values in 'path' with the values in 'newQuerystring'. Does not support the semicolon syntax.
path | |
newQuerystring |
Definition at line 220 of file PathUtils.cs.
|
inlinestatic |
Adds the querystring values in 'newQuerystring' to the querystring in Path, but does not overwrite values. Does not support the semicolon syntax.
path | |
newQuerystring |
Definition at line 234 of file PathUtils.cs.
|
inlinestatic |
Parses a querystring into a name/value collection. The given string cannot include path or fragment information - it must be just the querystring.
query | |
allowSemicolons | |
urlDecode |
Definition at line 408 of file PathUtils.cs.
|
inlinestatic |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values.
path |
Definition at line 344 of file PathUtils.cs.
|
inlinestatic |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values. Does not enforce correct syntax, I.E. '?key=value?key2=value2' is allowed. However, '&key=value?key2=value' will only get key2 parsed. When allowSemicolons is true, semicolon paths like ';key=value;key2=value2' are allowed, as are hybrid paths: ';key=value?key2=value2&key3=value3'.
path | |
allowSemicolons |
Definition at line 357 of file PathUtils.cs.
|
inlinestatic |
Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values. Does not enforce correct syntax, I.E. '?key=value?key2=value2' is allowed. However, '&key=value?key2=value' will only get key2 parsed. When allowSemicolons is true, semicolon paths like ';key=value;key2=value2' are allowed, as are hybrid paths: ';key=value?key2=value2&key3=value3'.
Does NOT parse fragments correctly.
path | |
allowSemicolons | |
beforeQuery | Returns the portion of the 'path' before the querystring. May include the scheme, server, port, path and path info, depending upon what 'path' contained. |
Definition at line 374 of file PathUtils.cs.
|
inlinestatic |
Like ParseQueryString, but permits the leading '?' to be omitted. Does not support the semicolon syntax.
path |
Definition at line 312 of file PathUtils.cs.
|
inlinestatic |
Like ParseQueryString, but permits the leading '?' to be omitted, and semicolons can be substituted for '&'
path |
Definition at line 322 of file PathUtils.cs.
|
inlinestatic |
Removes the extension from the filename or URL, leaving the querystring intact, where the extension is only the last extension segment. I.e, image.jpg.bmp.tiff?hi would be image.jpg.bmp?hi after this call. The querystring and fragment is maintained as-is. Semicolon syntax not supported.
path |
Definition at line 85 of file PathUtils.cs.
|
inlinestatic |
Removes all extension segments from the filename or URL, leaving the querystring intact. I.e, image.jpg.bmp.tiff?hi would be image?hi The querystring and fragment is maintained as-is. Semicolon syntax not supported.
path |
Definition at line 66 of file PathUtils.cs.
|
inlinestatic |
Allows a string to be filtered using the specified whitelisting expression (regex style).
I.e, "hi YOU 3", "a-z3" will produce "hi3".
text | |
chars |
Definition at line 560 of file PathUtils.cs.
|
inlinestatic |
Removes the query string from the specifed path. If the path is only a querystring, an empty string is returned. Does not support the semicolon syntax. Fragment is maintained as-is.
path |
Definition at line 199 of file PathUtils.cs.
|
inlinestatic |
Resolves app-relative paths to virtual paths. Does nothing with virtual or relative paths.
virtualPath |
Definition at line 150 of file PathUtils.cs.
Referenced by ImageResizer.ImageBuilder.GetStreamFromSource().
|
inlinestatic |
Turns relative paths into domain-relative paths. Turns app-relative paths into domain relative paths.
virtualPath |
Definition at line 162 of file PathUtils.cs.
|
inlinestatic |
Replaces variables in paths with their values. Ex. ~/uploads/thumbs/<guid>.<ext>. Standard variables are <ext> (the default extension for the final file type), <guid>, a randomly generated GUID, <filename>, the original filename without it's extension, <path>, the original path and filename without extension, <settings.width>, (any specified settings value except preset), <width> (final width), and <height> (final height).
pathWithVars | |
resolver |
Definition at line 524 of file PathUtils.cs.
|
inlinestatic |
Should be called SetFullExtension. Sets the file extension of the specified path to the specified value, returning the result. If an extension has multiple parts, it will replace all of them. Leading dots will be stripped from 'newExtension' and re-addd as required. The querystring and fragment is maintained as-is. Semicolon syntax not supported.
path | |
newExtension |
Definition at line 48 of file PathUtils.cs.
|
inlinestatic |
Converts aribtrary bytes to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /)
data |
Definition at line 437 of file PathUtils.cs.
|
inlinestatic |
Converts aribtrary strings to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /)
data |
Definition at line 454 of file PathUtils.cs.
delegate string ImageResizer.Util.PathUtils.VariableResolverCallback | ( | string | variableName | ) |
A method that resolves variable names to values for the ResolveVariablesInPath method
variableName |
|
staticget |
If not running in ASP.NET, returns the folder containing the DLL.
Definition at line 30 of file PathUtils.cs.
|
staticget |
Returns HostingEnvironment.ApplicationVirtualPath or "/", if asp.net is not running
Definition at line 22 of file PathUtils.cs.