blockly > FieldImage

FieldImage class

Class for an image on a block.


export declare class FieldImage extends Field<string> 

Extends: Field<string>


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


Property Modifiers Type Description
EDITABLE readonly (not declared) Editable fields usually show some sort of UI indicating they are editable. This field should not.
imageElement protected SVGImageElement | null The rendered field's image element.



isDirty_ protected boolean Used 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.
size_ protected Size


Method Modifiers Description
configure_(config) protected Configure the field based on the given map of options.
doClassValidation_(newValue) protected Ensure that the input value (the source URL) is a string.
doValueUpdate_(newValue) protected Update the value of this image field, and update the displayed image.
getFlipRtl() Get whether to flip this image in RTL
getText_() protected Use 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.
setAlt(alt) Set the alt text of this image.
setOnClickHandler(func) Set the function that is called when this image is clicked.
showEditor_() protected If field click is called, and click handler defined, call the handler.