Skip to main content

Home > blockly > FieldImage

FieldImage class

Class for an image on a block.

Signature:

export declare class FieldImage extends Field<string> 

Extends: Field<string>

Constructors

ConstructorModifiersDescription
(constructor)(src, width, height, alt, onClick, flipRtl, config)Constructs a new instance of the FieldImage class

Properties

PropertyModifiersTypeDescription
EDITABLEreadonly(not declared)Editable fields usually show some sort of UI indicating they are editable. This field should not.
imageElementprotectedSVGImageElement | nullThe rendered field's image element.
imageHeightprotected readonlynumber
isDirty_protectedbooleanUsed to tell if the field needs to be rendered the next time the block is rendered. Image fields are statically sized, and only need to be rendered at initialization.

Methods

MethodModifiersDescription
configure_(config)protectedConfigure the field based on the given map of options.
doClassValidation_(newValue)protectedEnsure that the input value (the source URL) is a string.
doValueUpdate_(newValue)protectedUpdate the value of this image field, and update the displayed image.
getFlipRtl()Get whether to flip this image in RTL
getText_()protectedUse the getText_ developer hook to override the field's text representation. Return the image alt text instead.
initView()Create the block UI for this image.
isClickable()Check whether this field should be clickable.
setAlt(alt)Set the alt text of this image.
setOnClickHandler(func)Set the function that is called when this image is clicked.
showEditor_()protectedIf field click is called, and click handler defined, call the handler.
updateSize_()