Contains all the methods to initialise and control the image editor.
- Source:
Methods
-
<static> action(postid, nonce, action)
-
Performs an image edit action.
Parameters:
Name Type Description postidnumber The post id. noncestring The nonce to verify the request. actionstring The action to perform on the image. The possible actions are: "scale" and "restore". - Since:
-
- 2.9.0
- Source:
Returns:
Executes a post request that refreshes the page when the action is performed. Returns false if a invalid action is given, or when the action cannot be performed.- Type
- boolean | void
-
<static> addStep(op, postid, nonce)
-
Adds an image edit action to the history.
Parameters:
Name Type Description opobject The original position. postidnumber The post id. noncestring The nonce. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> close(postid, warn)
-
Closes the image editor.
Parameters:
Name Type Description postidnumber The post id. warnbool Warning message. - Since:
-
- 2.9.0
- Source:
Returns:
Returns false if there is a warning.- Type
- void | bool
-
<static> crop(postid, nonce, t)
-
Crops the image.
Parameters:
Name Type Description postidnumber The post id. noncestring The nonce. tobject The target object. - Since:
-
- 2.9.0
- Source:
Returns:
Returns false if the crop button is disabled.- Type
- void | boolean
-
<static> filterHistory(postid, setSize)
-
Removes the last action from the image edit history. The history consist of (edit) actions performed on the image.
Parameters:
Name Type Description postidnumber The post id. setSizenumber 0 or 1, when 1 the image resets to its original size. - Since:
-
- 2.9.0
- Source:
Returns:
JSON string containing the history or an empty string if no history exists.- Type
- string
-
<static> flip(axis, postid, nonce, t)
-
Flips the image.
Parameters:
Name Type Description axisnumber The axle the image is flipped on. postidnumber The post id. noncestring The nonce. tobject The target element. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- boolean
-
<static> getSelRatio(postid)
-
Gets the selected aspect ratio.
Parameters:
Name Type Description postidnumber The post id. - Since:
-
- 2.9.0
- Source:
Returns:
The aspect ratio.- Type
- string
-
<static> getTarget(postid)
-
Gets the value from the image edit target. The image edit target contains the image sizes where the (possible) changes have to be applied to.
Parameters:
Name Type Description postidnumber The post id. - Since:
-
- 2.9.0
- Source:
Returns:
The value from the imagedit-save-target input field when available, or 'full' when not available.- Type
- string
-
<static> imgLoaded(postid)
-
Initializes the cropping tool and sets a default cropping selection.
Parameters:
Name Type Description postidnumber The post id. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> init(postid)
-
Initializes the image editor.
Parameters:
Name Type Description postidnumber The post id. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> initCrop(postid, image, parent)
-
Initializes the cropping tool.
Parameters:
Name Type Description postidnumber The post id. imageHTMLElement The preview image. parentHTMLElement The preview image container. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> intval(f)
-
Converts a value to an integer.
Parameters:
Name Type Description fnumber The float value that should be converted. - Since:
-
- 2.9.0
- Source:
Returns:
The integer representation from the float value.- Type
- number
-
<static> notsaved(postid)
-
Checks if the image edit history is saved.
Parameters:
Name Type Description postidnumber The post id. - Since:
-
- 2.9.0
- Source:
Returns:
Returns true if the history is not saved.- Type
- boolean
-
<static> open(postid, nonce, view)
-
Creates the image edit window.
Parameters:
Name Type Description postidnumber The post id for the image. noncestring The nonce to verify the request. viewobject The image editor view to be used for the editing. - Since:
-
- 2.9.0
- Source:
Returns:
Either returns void if the button was already activated or returns an instance of the image editor, wrapped in a promise.- Type
- void | promise
-
<static> redo(postid, nonce)
-
Reverts a undo action.
Parameters:
Name Type Description postidnumber The post id. noncestring The nonce. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> refreshEditor(postid, nonce, callback)
-
Binds the necessary events to the image. When the image source is reloaded the image will be reloaded.
Parameters:
Name Type Description postidnumber The post id. noncestring The nonce to verify the request. callbackfunction Function to execute when the image is loaded. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> rotate(angle, postid, nonce, t)
-
Rotates the image.
Parameters:
Name Type Description anglestring The angle the image is rotated with. postidnumber The post id. noncestring The nonce. tobject The target element. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- boolean
-
<static> round(num)
-
Rounds a number to a whole.
Parameters:
Name Type Description numnumber The number. - Since:
-
- 2.9.0
- Source:
Returns:
The number rounded to a whole number.- Type
- number
-
<static> save(postid, nonce)
-
Stores the changes that are made to the image.
Parameters:
Name Type Description postidnumber The post id to get the image from the database. noncestring The nonce to verify the request. - Since:
-
- 2.9.0
- Source:
Returns:
If the actions are successfully saved a response message is shown. Returns false if there is no image editing history, thus there are not edit-actions performed on the image.- Type
- boolean | void
-
<static> scaleChanged(postid, x, el)
-
Recalculates the height or width and keeps the original aspect ratio. If the original image size is exceeded a red exclamation mark is shown.
Parameters:
Name Type Description postidnumber The current post id. xnumber Is 0 when it applies the y-axis and 1 when applicable for the x-axis. eljQuery Element. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> setCropSelection(postid, c)
-
Stores the current crop selection.
Parameters:
Name Type Description postidnumber The post id. cobject The selection. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- boolean
-
<static> setDisabled(el, s)
-
Adds the disabled attribute and class to a single form element or a field set.
Parameters:
Name Type Description eljQuery The element that should be modified. sbool | number The state for the element. If set to true the element is disabled, otherwise the element is enabled. The function is sometimes called with a 0 or 1 instead of true or false. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> setNumSelection(postid, el)
-
Sets the selection for the height and width in pixels.
Parameters:
Name Type Description postidnumber The post id. eljQuery The element containing the values. - Since:
-
- 2.9.0
- Source:
Returns:
Returns false when the x or y value is lower than 1, void when the value is not numeric or when the operation is successful.- Type
- void | boolean
-
<static> setRatioSelection(postid, n, el)
-
Sets a locked aspect ratio for the selection.
Parameters:
Name Type Description postidnumber The post id. nnumber The ratio to set. eljQuery The element containing the values. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> toggleEditor(postid, toggle)
-
Toggles the wait/load icon in the editor.
Parameters:
Name Type Description postidnumber The post id. togglenumber Is 0 or 1, fades the icon in then 1 and out when 0. - Since:
-
- 2.9.0
- Source:
Returns:
- Type
- void
-
<static> toggleHelp(el)
-
Shows or hides the image edit help box.
Parameters:
Name Type Description elHTMLElement The element to create the help window in. - Since:
-
- 2.9.0
- Source:
Returns:
Always returns false.- Type
- boolean
-
<static> undo(postid, nonce)
-
Undoes an image edit action.
Parameters:
Name Type Description postidnumber The post id. noncestring The nonce. - Since:
-
- 2.9.0
- Source:
Returns:
Returns false if the undo button is disabled.- Type
- void | false
-
<static> validateNumeric(el)
-
Validates if a value in a jQuery.HTMLElement is numeric.
Parameters:
Name Type Description eljQuery The html element. - Since:
-
- 4.6.0
- Source:
Returns:
Returns false if the value is not numeric, void when it is.- Type
- void | boolean