API Docs for: 1.0.0
Show:

eZ.ImageEditView Class

The Image edit view

Constructor

Methods

_afterRender

() protected

Method called at the end of the render process. The default implementation does nothing, it is meant to be overridden in the view extending the binary base edit view.

_altTextChange

(
  • e
)
protected

Event handler for the valuechange event on the input field for the alternative text

Parameters:

_base64ToFileStruct

(
  • e
  • file
)
protected

Set the file attribute with a struct based on the file object from the input file element. This implementation adds a validation to check that the chosen file is really an image the browser can load.

Parameters:

  • e EventFacade

    event facade

  • file File

    the File object from the input file element

_beforeReadFile

() protected

Removes the being updated class before reading the image content.

_chooseFile

(
  • e
)
protected

Event handler for the tap event on the upload button

Parameters:

_completeFieldValue

(
  • fieldValue
)
Object protected

Completes the field value with the alternative text

Parameters:

  • fieldValue Object

Returns:

Object:

_createFileStruct

(
  • file
  • content
)
Object protected

Creates the image structure based on the File object provided by the input file and on the base64 encoded image content. It also creates a blob URL for the newly selected object.

Parameters:

  • file File
  • content String

    base64 encoded image content

Returns:

Object:

_drop

(
  • e
)
protected

Event handler for the drop DOM event.

Parameters:

_fileSetter

(
  • value
)
Object protected

image attribute setter. It converts the different input type to a consistent object no matter if the image attribute is filled from the REST fieldValue or from the user input.

Parameters:

  • value Object | Null

Returns:

Object:

_fireLoadImageVariation

() protected

Fire the loadImageVariation event

_getFieldValue

() Object | Null | Undefined protected

Returns the field value suitable for the REST API based on the current input. It makes to sure to only send the actual content when it's needed. It returns null if no file has been chosen yet or undefined if no change happened since the version save event.

Returns:

Object | Null | Undefined:

_getHumanMaxSize

() String protected

Returns a "human" readable version of the max allowed file size. It is overidden the max size is in byte in Image fields.

Returns:

String:

_getOverSizeMessage

(
  • name
)
String protected

Returns the warning message suitable when the user tries to use a too big file

Parameters:

  • name String

    the filename the user wants to use

Returns:

String:

_hideWarning

(
  • e
)
protected

Event handler for the tap event on the hide link of the warning box.

Parameters:

_initAttributesEvents

() protected

Initializes the attributes events handling

_isCreatingTranslation

() Boolean protected

Check if a new translation is being created.

Returns:

Boolean:

_isEmpty

() Boolean protected

Checks whether the file field is currently empty.

Returns:

Boolean:

_maxSize

() protected

Returns the maximum allowed size in bytes or 0 if no limit is set. The default implementation is overriden because in the case of the Image field, the field definition directly contains the maximum size in bytes while for BinaryFile and Media, this size is in megabytes.

Returns:

Number

_prepareDrop

(
  • e
)
protected

Event handler for the dragenter and dragover DOM event

Parameters:

_readFile

(
  • file
)
protected

Read the content of the choosen File (if its size match the field configuration) and update the file attribute with the corresponding structure

Parameters:

  • file File

    the File object from the input file element

_removeBinaryFile

(
  • e
)
protected

Event handler for the tap event on the remove button

Parameters:

_removeImageBeingUpdatedClass

() protected

Removes the image being updated class

_setStateClasses

() protected

Set the state classes on the view container

_setWarningNotAnImage

(
  • file
)
protected

Sets a warning because the file is not an image

Parameters:

  • file File

    the File object from the input file element

_toggleClass

(
  • Mixed
  • cl
)
private

Toggle a class on the view container based on the value

Parameters:

  • Mixed Object

    value

  • cl String

    the class to toggle

_trackVersionSave

() private

Sets the updated attribute to false when the attached version is saved. This is to avoid sending again and again the same file

_uiHandleWarningMessage

() protected

warningChange event handler, it displays/hides the warning message depending on the attribute value.

_uiImageChange

() protected

Reflects the new image object in the generated UI

_uiPrepareDropArea

(
  • the
)
protected

Prepares visually the drop area

Parameters:

_uiResetDropArea

() protected

Resets visually the drop area

_updateFile

(
  • e
)
protected

Event handler for the change event on the file input

Parameters:

_valid

(
  • file
)
protected

Checks whether the File in parameter is valid for the field. It checks the size of the selected file and its mime type.

Parameters:

  • file File

    the File object to be stored in the field

Returns:

Boolean

_validSize

(
  • file
)
Boolean private

Checks whether the size is valid according to the field definition configuration. If the file can not be accepted, a warning message is set in the warning attribute.

Parameters:

  • file File

    the File object to be stored in the field

Returns:

Boolean:

_validType

(
  • file
)
protected

Checks that the file represents a valid image file the Image field type. In case of error, a warning message is set in the warning

Parameters:

  • file File

    the File object to be stored in the field

Returns:

Boolean

_variables

() Object protected

Defines the variables to be imported in the field edit template.

Returns:

Object:

validate

()

Validates the current input of the image against the is required field definition setting.

Attributes

alternativeText

String readonly

The alternative image text

file

Object | Null readonly

The file struct object for the current field. This attribute has a setter to accept either null value, any REST fieldValue or an object created from a File.

fileReader

FileReader readonly

FileReader instance

imageVariation

Object

The image variation to display

updated

Boolean readonly

Flag indicating whether the user changed something in the binaryfile field. This attribute is used to avoid sending the same binaryfile again and again.

variationIdentifier

String

The variation identifier to use to display the image

Default: 'platformui_rawcontentview'

warning

String | False readonly

Stores the warning message (if any) or false

Events

loadImageVariation

Fired when the view needs the image variation

Event Payload:

  • field Object

    the Image field

  • variation String

    the variation name (large, reference, ...)