Sign up (with export icon)

image/image/converters

Api-module iconmodule

Functions

  • Chevron-right icon

    downcastImageAttribute( imageUtils, imageType, attributeKey ) → ( dispatcher: DowncastDispatcher ) => void
    internal

    Converter used to convert a given image attribute from the model to the view.

    Parameters

    imageUtils : ImageUtils
    imageType : 'imageBlock' | 'imageInline'

    The type of the image.

    attributeKey : string

    The name of the attribute to convert.

    Returns

    ( dispatcher: DowncastDispatcher ) => void
  • Chevron-right icon

    downcastSourcesAttribute( imageUtils ) → ( dispatcher: DowncastDispatcher ) => void
    internal

    Converts the source model attribute to the <picture><source /><source />...<img /></picture> view structure.

    Parameters

    imageUtils : ImageUtils

    Returns

    ( dispatcher: DowncastDispatcher ) => void
  • Chevron-right icon

    downcastSrcsetAttribute( imageUtils, imageType ) → ( dispatcher: DowncastDispatcher ) => void
    internal

    Converter used to convert the srcset model image attribute to the srcset and sizes attributes in the view.

    Parameters

    imageUtils : ImageUtils
    imageType : 'imageBlock' | 'imageInline'

    The type of the image.

    Returns

    ( dispatcher: DowncastDispatcher ) => void
  • Chevron-right icon

    upcastImageFigure( imageUtils ) → ( dispatcher: UpcastDispatcher ) => void
    internal

    Returns a function that converts the image view representation:

    <figure class="image"><img src="..." alt="..."></img></figure>
    
    Copy code

    to the model representation:

    <imageBlock src="..." alt="..."></imageBlock>
    
    Copy code

    The entire content of the <figure> element except the first <img> is being converted as children of the <imageBlock> model element.

    Parameters

    imageUtils : ImageUtils

    Returns

    ( dispatcher: UpcastDispatcher ) => void
  • Chevron-right icon

    upcastImg( matchImageType, imageUtils ) → ( dispatcher: UpcastDispatcher ) => void
    internal

    Returns a function that upcasts an <img> element to either an imageBlock or an imageInline model element.

    The image type is first determined from the view structure (see getViewImageType): an <img> wrapped in a <figure class="image"> or styled with display: block becomes an imageBlock, otherwise an imageInline.

    That structural type is then verified against the schema at the insertion position. If it cannot be placed there - neither directly (or after hoisting to an allowed ancestor) nor wrapped in an auto-created paragraph - the converter falls back to matchImageType. This is what allows a block image to degrade to an inline image inside an inline root (and, symmetrically, an inline image to become a block image in a context that only accepts block images) instead of being dropped.

    Both ImageBlockEditing and ImageInlineEditing register this converter, each passing the type it falls back to. When only one of them is loaded, that single type is always produced.

    Parameters

    matchImageType : 'imageBlock' | 'imageInline'

    The image type to fall back to when the type resolved from the view cannot be placed at the insertion position.

    imageUtils : ImageUtils

    The ImageUtils plugin instance.

    Returns

    ( dispatcher: UpcastDispatcher ) => void
  • Chevron-right icon

    upcastPicture( imageUtils ) → ( dispatcher: UpcastDispatcher ) => void
    internal

    Returns a function that converts the image view representation:

    <picture><source ... /><source ... />...<img ... /></picture>
    
    Copy code

    to the model representation as the sources attribute:

    <image[Block|Inline] ... sources="..."></image[Block|Inline]>
    
    Copy code

    Parameters

    imageUtils : ImageUtils

    Returns

    ( dispatcher: UpcastDispatcher ) => void