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.
Inherited Members
Namespace: ToSic.Sxc.Services
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi]
public interface IImageService : ICanDebug
Remarks
History: Released 2sxc 13.10
Methods
| Improve this Doc View SourceImg(object, object, string, object, object, string, string, string, object, 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 = "Params must be named (https://go.2sxc.org/named-params)", object factor = null, object width = null, string imgAlt = null, string imgAltFallback = null, string imgClass = null, object toolbar = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
object | link | What should be in this, can be:
|
object | settings |
|
string | noParamOrder | |
object | factor | An optional multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
object | width | An optional, fixed width of the image |
string | imgAlt | Optional |
string | imgAltFallback | Optional |
string | imgClass | Optional |
object | toolbar | Provide a custom toolbar or |
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
- Added in 2sxc 13.03
toolbar
added in v16.04
Picture(object, object, string, object, object, string, string, string, object, 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 = "Params must be named (https://go.2sxc.org/named-params)", object factor = null, object width = null, string imgAlt = null, string imgAltFallback = null, string imgClass = null, object toolbar = null, object recipe = null)
Parameters
Type | Name | Description |
---|---|---|
object | link | What should be in this, can be: |
object | settings |
|
string | noParamOrder | |
object | factor | An optional multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
object | width | An optional, fixed width of the image |
string | imgAlt | Optional |
string | imgAltFallback | Optional |
string | imgClass | Optional |
object | toolbar | Provide a custom toolbar or |
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
- Added in v13.03
- Extended in v16.03 to also support IFile
toolbar
added in v16.04
Recipe(string)
Declaration
Recipe Recipe(string variants)
Parameters
Type | Name | Description |
---|---|---|
string | variants |
Returns
Type | Description |
---|---|
Recipe |
Recipe(Recipe, string, string, int, string, IDictionary<string, object>, IEnumerable<Recipe>, bool?, bool?, string, string, string)
Declaration
Recipe Recipe(Recipe recipe, string noParamOrder = "Params must be named (https://go.2sxc.org/named-params)", string name = null, int width = 0, string variants = null, IDictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null, bool? setWidth = null, bool? setHeight = null, string forTag = null, string forFactor = null, string forCss = null)
Parameters
Type | Name | Description |
---|---|---|
Recipe | recipe | |
string | noParamOrder | |
string | name | |
int | width | |
string | variants | |
IDictionary<string, object> | attributes | |
IEnumerable<Recipe> | recipes | |
bool? | setWidth | |
bool? | setHeight | |
string | forTag | |
string | forFactor | |
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 = "Params must be named (https://go.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 |
---|---|---|
object | settings |
|
string | noParamOrder | |
object | factor | A multiplier, usually used to create urls which resize to a part of the default content-size. Eg. 0.5. |
object | width | Optional width parameter. Cannot be used if |
object | height | Optional height parameter. Can only be 0 if |
object | quality | Optional quality parameter. Usually takes the default from the |
string | resizeMode | Optional resize-mode, like |
string | scaleMode | Optional scale-mode to allow up-scaling images like |
string | format | Optional file format like |
object | aspectRatio | Aspect Ratio width/height, only relevant if a |
string | parameters |
|
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