Interface IImageService
Service to help create responsive img
and picture
tags the best possible way.
This service helps you generate advanced HTML for responsive / resized images.
Namespace: ToSic.Sxc.Services
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi("Still WIP")]
public interface IImageService : ICanDebug
Remarks
History: Released 2sxc 13.10
Methods
| Improve this Doc View SourceImg(Object, Object, String, Object, Object, String, String, Object)
Get a Responsive Image object which you can then either just show, or use to construct a more customized output as you need it.
The resulting object can just be added to the html, like @img
or you can work with sub-properties as specified in the IResponsiveImage
Declaration
IResponsiveImage Img(object link = null, object settings = null, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object factor = null, object width = null, string imgAlt = null, string imgClass = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | link | What should be in this, can be:
|
System.Object | settings |
Note: If you need to construct very custom settings, use Settings(Object, String, Object, Object, Object, Object, String, String, String, Object, String, Object) to create them |
System.String | noParamOrder | |
System.Object | factor | A multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
System.Object | width | |
System.String | imgAlt |
|
System.String | imgClass |
|
System.Object | recipe | Optional recipe = instructions how to create the various variants of this link. Can be any one of these:
TODO: DOCS not quite ready |
Returns
Type | Description |
---|---|
IResponsiveImage | A ResponsiveImage object which can be rendered directly. See Responsive Images API in .net |
Remarks
History: Added in 2sxc 13.03
ImgOrPic(Object, Object, String, Object, Object, String, String, Object)
Determine the best scenario (has multiple formats or not) and then return either an img
(if it is not resizable and/or not multiple formats) or a picture
The resulting object can just be added to the html, like @img
or you can work with sub-properties as specified in the IResponsiveImage
Declaration
IResponsiveImage ImgOrPic(object link = null, object settings = null, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object factor = null, object width = null, string imgAlt = null, string imgClass = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | link | What should be in this, can be:
|
System.Object | settings |
Note: If you need to construct very custom settings, use Settings(Object, String, Object, Object, Object, Object, String, String, String, Object, String, Object) to create them |
System.String | noParamOrder | |
System.Object | factor | A multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
System.Object | width | |
System.String | imgAlt |
|
System.String | imgClass |
|
System.Object | recipe | Optional recipe = instructions how to create the various variants of this link. Can be any one of these:
TODO: DOCS not quite ready |
Returns
Type | Description |
---|---|
IResponsiveImage | A ResponsiveImage object which can be rendered directly. See Responsive Images API in .net |
Remarks
History: Added in 2sxc 13.03
Picture(Object, Object, String, Object, Object, String, String, Object)
Get a Responsive Picture object which you can then either just show, or use to construct a more customized output as you need it.
The resulting object can just be added to the html, like @pic
or you can work with sub-properties as specified in the IResponsivePicture.
Important: This call only allows you to set the most common parameters factor
and width
.
For other parameters like height
, aspectRatio
, quality
etc. create Settings Settings(Object, String, Object, Object, Object, Object, String, String, String, Object, String, Object) and pass them in.
Declaration
IResponsivePicture Picture(object link = null, object settings = null, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object factor = null, object width = null, string imgAlt = null, string imgClass = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | link | What should be in this, can be:
|
System.Object | settings |
Note: If you need to construct very custom settings, use Settings(Object, String, Object, Object, Object, Object, String, String, String, Object, String, Object) to create them |
System.String | noParamOrder | |
System.Object | factor | A multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
System.Object | width | |
System.String | imgAlt |
|
System.String | imgClass |
|
System.Object | recipe | Optional recipe = instructions how to create the various variants of this link. Can be any one of these:
TODO: DOCS not quite ready |
Returns
Type | Description |
---|---|
IResponsivePicture | A ResponsivePicture object which can be rendered directly. See Responsive Images API in .net |
Remarks
History: Added in 2sxc 13.03
Recipe(String)
Declaration
Recipe Recipe(string variants)
Parameters
Type | Name | Description |
---|---|---|
System.String | variants |
Returns
Type | Description |
---|---|
Recipe |
Recipe(Recipe, String, String, Int32, String, Dictionary<String, Object>, IEnumerable<Recipe>, Nullable<Boolean>, Nullable<Boolean>, String, String, String)
Declaration
Recipe Recipe(Recipe recipe, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", string name = null, int width = 0, string variants = null, Dictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null, bool? setWidth = default(bool? ), bool? setHeight = default(bool? ), string forTag = null, string forFactor = null, string forCss = null)
Parameters
Type | Name | Description |
---|---|---|
Recipe | recipe | |
System.String | noParamOrder | |
System.String | name | |
System.Int32 | width | |
System.String | variants | |
System.Collections.Generic.Dictionary<System.String, System.Object> | attributes | |
System.Collections.Generic.IEnumerable<Recipe> | recipes | |
System.Nullable<System.Boolean> | setWidth | |
System.Nullable<System.Boolean> | setHeight | |
System.String | forTag | |
System.String | forFactor | |
System.String | forCss |
Returns
Type | Description |
---|---|
Recipe |
Settings(Object, String, Object, Object, Object, Object, String, String, String, Object, String, Object)
Construct custom Resize-Settings as needed, either based on existing settings or starting from scratch
Declaration
IResizeSettings Settings(object settings = null, string noParamOrder = "Rule: All params must be named (https://r.2sxc.org/named-params)", object factor = null, object width = null, object height = null, object quality = null, string resizeMode = null, string scaleMode = null, string format = null, object aspectRatio = null, string parameters = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | settings |
|
System.String | noParamOrder | |
System.Object | factor | A multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
System.Object | width | Optional width parameter. Cannot be used if |
System.Object | height | Optional height parameter. Can only be 0 if |
System.Object | quality | Optional quality parameter. Usually takes the default from the |
System.String | resizeMode | Optional resize-mode, like |
System.String | scaleMode | Optional scale-mode to allow up-scaling images like |
System.String | format | Optional file format like |
System.Object | aspectRatio | Aspect Ratio width/height, only relevant if a |
System.String | parameters |
|
System.Object | recipe | WIP - not ready yet |
Returns
Type | Description |
---|---|
IResizeSettings | A settings object which has all the parameters as configured |
Remarks
History: Added in 2sxc 13.03