Interface IResponsiveImage
A object which contains everything to create HTML for responsive img
tags with optimal srcset
offering all the sizes you may need.
You can simply add this object to the source, like @image
to render the image - which is the same as @image.ImgTag
Namespace: ToSic.Sxc.Images
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi]
public interface IResponsiveImage : IHybridHtmlString, IHtmlString
Remarks
History: Released 2sxc 13.10
Properties
| Improve this Doc View SourceAlt
An Alt-description on the image which is retrieved from (in order of priority):
- the Razor code creating this object using the parameter
imgAlt
- or from image metadata - see Description
- or from the Razor code using the parameter
imgAltFallback
new v15
Declaration
string Alt { get; }
Property Value
Type | Description |
---|---|
System.String |
Class
The Class of the image. Usually created from these sources
- The initial call creating this image tag
- Resize-Settings which may add classes
- Rule which determines if the image should crop or not, which may add a class
Declaration
string Class { get; }
Property Value
Type | Description |
---|---|
System.String |
Description
Image description from the image Metadata. See also Alt.
Declaration
string Description { get; }
Property Value
Type | Description |
---|---|
System.String |
|
Remarks
Added in v15
Height
The image height, if it should be set at all. Will be null otherwise.
Declaration
string Height { get; }
Property Value
Type | Description |
---|---|
System.String |
Img
The img
tag which would normally be added to the page automatically.
You can also use the normal RazorBlade API and do things like .Alt("description")
etc.
See also the RazorBlade Img docs
Declaration
Img Img { get; }
Property Value
Type | Description |
---|---|
ToSic.Razor.Html5.Img |
ShowAll
Determines if the image should be shown entirely. This usually means that the image is a logo or something, so cropping was not an option. This also usually means that the aspect ratio / height may be different than expected
Declaration
bool ShowAll { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Sizes
The sizes in case you need it in your custom img-tag.
It will only be used for normal img
tags, but not for img
tags inside picture
tags.
Declaration
string Sizes { get; }
Property Value
Type | Description |
---|---|
System.String |
Src
The main url, used for main src
property
Declaration
string Src { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Added in v13.11
SrcSet
The SrcSet in case you need to use it in your own custom img-tag. Note that it will be null if the image has no reason to have a srcset.
It will only be used for normal img
tags, but not for img
tags inside picture
tags.
Declaration
string SrcSet { get; }
Property Value
Type | Description |
---|---|
System.String |
Width
The image width, if it should be set at all. Will be null otherwise.
Declaration
string Width { get; }
Property Value
Type | Description |
---|---|
System.String |