eZ.ImageEditView Class
The Image edit view
Constructor
eZ.ImageEditView
()
Item Index
Methods
- _afterRender
- _altTextChange
- _base64ToFileStruct
- _beforeReadFile
- _chooseFile
- _completeFieldValue
- _createFileStruct
- _drop
- _fileSetter
- _fireLoadImageVariation
- _getFieldValue
- _getHumanMaxSize
- _getOverSizeMessage
- _hideWarning
- _initAttributesEvents
- _isCreatingTranslation
- _isEmpty
- _maxSize
- _prepareDrop
- _readFile
- _removeBinaryFile
- _removeImageBeingUpdatedClass
- _setStateClasses
- _setWarningNotAnImage
- _toggleClass
- _trackVersionSave
- _uiHandleWarningMessage
- _uiImageChange
- _uiPrepareDropArea
- _uiResetDropArea
- _updateFile
- _valid
- _validSize
- _validType
- _variables
- validate
Events
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
Event handler for the valuechange event on the input field for the alternative text
Parameters:
-
e
EventFacadeevent facade of the valuechange event
_base64ToFileStruct
-
e
-
file
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
EventFacadeevent facade
-
file
Filethe File object from the input file element
_beforeReadFile
()
protected
Removes the being updated class before reading the image content.
_chooseFile
-
e
Event handler for the tap event on the upload button
Parameters:
-
e
EventFacadeevent facade of the tap event
_completeFieldValue
-
fieldValue
Completes the field value with the alternative text
Parameters:
-
fieldValue
Object
Returns:
_createFileStruct
-
file
-
content
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
Stringbase64 encoded image content
Returns:
_fileSetter
-
value
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:
_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:
_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:
_getOverSizeMessage
-
name
Returns the warning message suitable when the user tries to use a too big file
Parameters:
-
name
Stringthe filename the user wants to use
Returns:
_hideWarning
-
e
Event handler for the tap event on the hide link of the warning box.
Parameters:
-
e
EventFacadetap event facade
_initAttributesEvents
()
protected
Initializes the attributes events handling
_isCreatingTranslation
()
Boolean
protected
Check if a new translation is being created.
Returns:
_isEmpty
()
Boolean
protected
Checks whether the file field is currently empty.
Returns:
_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
Event handler for the dragenter and dragover DOM event
Parameters:
_readFile
-
file
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
Filethe File object from the input file element
_removeBinaryFile
-
e
Event handler for the tap event on the remove button
Parameters:
-
e
EventFacadeevent facade of tap event
_removeImageBeingUpdatedClass
()
protected
Removes the image being updated class
_setStateClasses
()
protected
Set the state classes on the view container
_setWarningNotAnImage
-
file
Sets a warning because the file is not an image
Parameters:
-
file
Filethe File object from the input file element
_toggleClass
-
Mixed
-
cl
Toggle a class on the view container based on the value
Parameters:
-
Mixed
Objectvalue
-
cl
Stringthe 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
Prepares visually the drop area
Parameters:
-
the
EventFacadeevent facade of the drag* event
_uiResetDropArea
()
protected
Resets visually the drop area
_updateFile
-
e
Event handler for the change event on the file input
Parameters:
-
e
EventFacadeevent facade of the change event
_valid
-
file
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
Filethe File object to be stored in the field
Returns:
Boolean
_validSize
-
file
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
Filethe File object to be stored in the field
Returns:
_validType
-
file
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
Filethe 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:
validate
()
Validates the current input of the image against the is required field definition setting.
Attributes
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.
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.
Events
loadImageVariation
Fired when the view needs the image variation
Event Payload:
-
field
Objectthe Image field
-
variation
Stringthe variation name (large, reference, ...)