• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API
v16
Search Results for

    Show / Hide Table of Contents

    Class Recipe

    A recipe contains instructions how to generate tags etc. which can contain multiple resized images

    Inheritance
    object
    Recipe
    Implements
    ICanDump
    Namespace: ToSic.Sxc.Images
    Assembly: ToSic.Sxc.dll
    Syntax
    [PublicApi("Still Beta / WIP")]
    public class Recipe : ICanDump
    Remarks

    All the properties are read-only. If you need to override anything, copy it and set the modified values, then use the copy.

    Constructors

    | Improve this Doc View Source

    Recipe(string, string, string, string, int, bool?, bool?, string, IDictionary<string, object>, IEnumerable<Recipe>)

    Lighter constructor for json, without parameter Recipe.

    Important If you call this from your code, always use named parameters, as the parameter order can change in future.

    Declaration
    [JsonConstructor]
    public Recipe(string name = null, string forTag = null, string forFactor = null, string forCss = null, int width = 0, bool? setWidth = null, bool? setHeight = null, string variants = null, IDictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null)
    Parameters
    Type Name Description
    string name

    An optional name

    string forTag

    Restricts the rule to only apply to specific tags - ATM img and source

    string forFactor

    Restricts the rule to only apply to resizes for a specified factor

    string forCss

    Restricts the rule to only apply to pages which have the specified CSS Framework

    int width

    Initial width to use when resizing

    bool? setWidth

    Set the width attribute if the img width is known

    bool? setHeight

    Set the height attribute if the img-height is known

    string variants

    Special string containing variants to generate

    IDictionary<string, object> attributes

    List of attributes to set on the img tag

    IEnumerable<Recipe> recipes

    List of additional recipes which will all inherit values from this master after creation

    | Improve this Doc View Source

    Recipe(Recipe, string, string, string, string, int, bool?, bool?, string, IDictionary<string, object>, IEnumerable<Recipe>)

    Important

    If you call this from your code, always use named parameters, as the parameter order can change in future.

    Declaration
    public Recipe(Recipe original, string name = null, string forTag = null, string forFactor = null, string forCss = null, int width = 0, bool? setWidth = null, bool? setHeight = null, string variants = null, IDictionary<string, object> attributes = null, IEnumerable<Recipe> recipes = null)
    Parameters
    Type Name Description
    Recipe original

    An original recipe to copy if we want to get a modified recipe based on one which already existed.

    string name

    An optional name

    string forTag

    Restricts the rule to only apply to specific tags - ATM img and source

    string forFactor

    Restricts the rule to only apply to resizes for a specified factor

    string forCss

    Restricts the rule to only apply to pages which have the specified CSS Framework

    int width

    Initial width to use when resizing

    bool? setWidth

    Set the width attribute if the img width is known

    bool? setHeight

    Set the height attribute if the img-height is known

    string variants

    Special string containing variants to generate

    IDictionary<string, object> attributes

    List of attributes to set on the img tag

    IEnumerable<Recipe> recipes

    List of additional recipes which will all inherit values from this master after creation

    Properties

    | Improve this Doc View Source

    Attributes

    Attributes to add to the img tag

    Declaration
    public IDictionary<string, object> Attributes { get; }
    Property Value
    Type Description
    IDictionary<string, object>
    Remarks

    System.Text.Json requires that the case-insensitive property name and type match the parameter in the constructor. We are using string/object because a value could also be { "name": true, "other-name": 5 } in the json configuration

    | Improve this Doc View Source

    ForCss

    WIP, not implemented yet

    Declaration
    public string ForCss { get; set; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    ForFactor

    Determines which factors this recipe should be applied to. Null means any factor.

    Declaration
    public string ForFactor { get; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    ForTag

    TODO: DOC

    • img, source
    Declaration
    public string ForTag { get; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    Name

    Just an identifier - no technical use

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    Recipes

    wip TODO: DOC

    Declaration
    public IEnumerable<Recipe> Recipes { get; }
    Property Value
    Type Description
    IEnumerable<Recipe>
    Remarks

    System.Text.Json requires that the case-insensitive property name and type match the parameter in the constructor.

    | Improve this Doc View Source

    SetHeight

    Determines if the img tag will receive a height-attribute

    Declaration
    public bool? SetHeight { get; }
    Property Value
    Type Description
    bool?
    | Improve this Doc View Source

    SetWidth

    Determines if the img tag will receive a width-attribute

    Declaration
    public bool? SetWidth { get; }
    Property Value
    Type Description
    bool?
    | Improve this Doc View Source

    Variants

    Source-Set rules (comma separated) which will determine what will be generated.

    Examples:

    • 1x,1.5x,2x - screen resolutions
    • 200w,400w,600w,800w,1000w - pixel sizes
    • 0.5*,1*,1.5*,2* - multipliers of the originally specified pixel size

    Important: According to the HTML standard you can mix pixel-sizes and multipliers, but not resolutions with any of the other types.

    Declaration
    public string Variants { get; }
    Property Value
    Type Description
    string
    | Improve this Doc View Source

    Width

    The initial width to assume in this resize, from which other sizes would be calculated.

    If set to 0, it will be ignored.

    Declaration
    public int Width { get; }
    Property Value
    Type Description
    int

    Methods

    | Improve this Doc View Source

    Dump()

    Create a string dump of the current objects state/contents.

    Declaration
    public string Dump()
    Returns
    Type Description
    string

    Implements

    ICanDump
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX