InputfieldImage
Image upload Inputfield for FieldtypeImage fields
It renders a sortable thumbnail grid with inline descriptions, focus point controls, image editor buttons, variation management, optional client-side resizing, and all inherited InputfieldFile upload behavior.
$f = $modules->get('InputfieldImage');
$f->name = 'photos';
$f->label = 'Photos';
$f->maxFiles = 5;
$f->extensions = 'JPG JPEG GIF PNG';
$f->maxWidth = 2000;
$f->maxHeight = 2000;
$f->gridMode = 'grid'; // grid, left, or list In normal page editing, this Inputfield is created by FieldtypeImage, which sets the page, field, value, destination path hook, and field settings. For standalone file-upload behavior, also read InputfieldFile. For shared Inputfield attributes, labels, rendering, processing, errors, and visibility selectors, see Inputfield.
Expand all Collapse all API reference
Properties marked * default from $config->adminThumbOptions and may be
overridden on the Inputfield instance.
| Property | Type | Default | Description |
|---|---|---|---|
extensions | string | 'JPG JPEG GIF PNG' | Space-separated allowed image extensions. |
okExtensions | array | [] | Manually whitelisted extensions, such as ['SVG']. |
maxWidth | int|string | '' | Maximum uploaded image width in pixels; larger images are resized unless maxReject is enabled. |
maxHeight | int|string | '' | Maximum uploaded image height in pixels; larger images are resized unless maxReject is enabled. |
maxSize | float | 0.0 | Max megapixels for client-side resize, such as 1.7; alternative to max width/height. |
maxReject | bool|int | 0 | Reject images that exceed max dimensions rather than resizing them. |
minWidth | int|string | '' | Minimum uploaded image width in pixels. |
minHeight | int|string | '' | Minimum uploaded image height in pixels. |
dimensionsByAspectRatio | bool|int | 0 | Swap min/max width and height rules for portrait images. |
itemClass | string | 'gridImage ui-widget' | CSS classes used for each rendered image item. Append rather than replace unless you need full control. |
useImageEditor | int|bool | 1 | Whether crop, focus, variations, and action controls are available. Permission checks can disable it during render/process. |
adminThumbScale | int|float | from config | Deprecated compatibility setting; use gridSize. |
resizeServer | int|bool | 0 | 0 allows client-side resize when possible; 1 forces server-side resize. |
clientQuality | int | 90 | Client-side JPEG quality percentage. |
editFieldName | string | '' | Field name to use in image editor URLs; blank uses the inputfield name. |
gridSize * | int | 130 | Square admin thumbnail size in pixels. Values below 100 or 260+ fall back to 130. |
gridMode * | string | 'grid' | Admin display mode: grid, left, or list. |
focusMode * | string | 'on' | Focus UI mode: on, zoom, or off. |
imageSizerOptions * | array | [] | Options passed to ImageSizer for admin thumbnails. |
Inherited InputfieldFile properties such as maxFiles, maxFilesize,
overwrite, descriptionRows, useTags, tagsList, noUpload, noAjax, and
destinationPath also apply.
| Constant | Value | Description |
|---|---|---|
defaultGridSize | 130 | Default admin thumbnail grid size in pixels. |
debugRenderValue | false | Development-only flag to force render-value mode. |
render()
Render the complete image input: image grid, editor controls, upload area, and hidden data fields.
echo $f->render();renderList($value)
Render the thumbnail grid list. $value is usually a Pageimages collection.
$html = $f->renderList($page->images);renderItem(Pageimage $pagefile, $id, $n)
Render one image item, including thumbnail, hover controls, edit fields, action select, sort input, replace input, rename input, and focus input.
$wire->addHookAfter('InputfieldImage::renderItem', function(HookEvent $event) {
$event->return .= '<div class="my-extra-tool"></div>';
}); renderUpload($value)
Render the image upload button/drop target. The rendered input name receives
[] unless the name already ends with ].
renderButtons(Pageimage $pagefile, $id, $n)
Render the crop/focus/variations button toolbar. Returns an empty string when
useImageEditor is false.
renderAdditionalFields(Pageimage $pagefile, $id, $n)
Empty hook target for adding per-image markup below the description fields.
$wire->addHookAfter('InputfieldImage::renderAdditionalFields', function(HookEvent $event) {
$image = $event->arguments(0); /** @var Pageimage $image */
$event->return = "<p>{$image->width} x {$image->height}</p>";
}); getAdminThumb(Pageimage $img, $useSizeAttributes = true, $remove = false)
Return admin thumbnail data as an array with keys:
| Key | Description |
|---|---|
thumb | The thumbnail Pageimage used for markup. |
attr | Image attribute array including src, alt, data-w, data-h, data-original, and data-focus. |
markup | <img> markup. |
amarkup | Linked <img> markup. |
error | Thumbnail generation error text, or blank. |
title | Human-readable title text. |
$thumb = $f->getAdminThumb($pageimage, false);
echo $thumb['markup'];buildTooltipData(Pageimage $pagefile)
Return tooltip rows as [label, value] pairs. Default rows include dimensions,
filesize, variation count, and indicators for hidden status, description, and
tags when present.
$wire->addHookAfter('InputfieldImage::buildTooltipData', function(HookEvent $event) {
$data = $event->return;
$data[] = ['EXIF', 'Available'];
$event->return = $data;
}); getImageEditButtons($pagefile, $id, $n, $buttonClass)
Return an array of crop, focus, and variations buttons. Hook after this method to add or remove editor buttons. Added in 3.0.212.
getImageThumbnailActions($pagefile, $id, $n, $class)
Return icon-only thumbnail hover actions. The default return value is an empty array; hooks may add actions. Added in 3.0.212.
getFileActions(Pageimage $pagefile)
Return actions for the image action dropdown, such as duplicate, hide/unhide,
flip, rotate, grayscale, sepia, reduce 50%, and remove focus where applicable.
The available actions depend on maxFiles, image extension, installed image
engines, hidden status, and focus state.
$wire->addHookAfter('InputfieldImage::getFileActions', function(HookEvent $event) {
$image = $event->arguments(0); /** @var Pageimage $image */
$actions = $event->return;
$actions['exif'] = 'Get EXIF data';
$event->return = $actions;
}); processUnknownFileAction(Pageimage $pagefile, $action, $label)
Hook target for processing custom actions added through getFileActions().
Return true on success, false on failure, or null when not handled.
$wire->addHookAfter('InputfieldImage::processUnknownFileAction', function(HookEvent $event) {
$image = $event->arguments(0); /** @var Pageimage $image */
$action = $event->arguments(1);
if($action === 'exif') {
$event->message('EXIF action handled for ' . $image->name);
$event->return = true;
}
}); processInput(WireInputData $input)
Process uploads, deletions, descriptions, tags, sorting, focus values, and image actions. Image actions are processed only for non-AJAX saves.
processInputFile(WireInputData $input, Pageimage $pagefile, $n)
Process one image item. This extends InputfieldFile item processing with
focus-point handling. Empty focus input resets to 50 50 0. Changed focus
values rebuild variations.
fileAdded(Pagefile $pagefile)
Validate and post-process a newly uploaded image. Non-SVG images must have readable dimensions, are checked against min/max dimensions, and may be resized to max dimensions. SVG files bypass pixel-dimension validation and image editor operations.
- Access via
$modules->get('Inputfield, or let FieldtypeImage create it automatically for image fields.Image') - Client-side resize loads
piexif.jsandPWImageResizer.jswhen resize limits are configured andresizeServer=0. - Focus values are stored on the Pageimage as
top left zoom, for example25 75 0. renderSingleItem()is deprecated and no longer used by core.- SVG may be allowed by adding it to
extensionsandokExtensions, but SVG does not use the image editor, dimension validation, or raster image actions. - For upload constraints, overwrite behavior, tags, descriptions, and custom Pagefile fields, see InputfieldFile.
Source files: wire/modules/Inputfield/Inputfield,
wire/modules/Inputfield/Inputfield
API reference: methods, properties, hooks
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Inputfield class also inherits all the methods and properties of: InputfieldFile, Inputfield, WireData and Wire.
Common
| Name | Return | Summary | |
|---|---|---|---|
Inputfield Inputfield Inputfield | array bool mixed string null | Get setting or attribute | |
Inputfield Inputfield Inputfield | array | Get thumbnail image info | |
Inputfield Inputfield Inputfield | InputfieldWrapper | Configure field | |
Inputfield Inputfield Inputfield | $this | Process input | |
Inputfield Inputfield Inputfield | string | Render Inputfield | |
Inputfield Inputfield Inputfield | bool | Called right before Inputfield render |
For hooks
These methods are only useful for hooking and should not be called directly.
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | int | for backwards compatibility only DEFAULT: auto | |
| Inputfield | int | Quality setting to use for client-side resize. 60=60%, 90=90%, etc. . DEFAULT: 90 | |
| Inputfield | bool int | Switch min-/maxWidth and min-/maxHeight restriction for portrait images | |
| Inputfield | string | Field name to use for linking to image editor DEFAULT: auto | |
| Inputfield | string | Space separated list of allowed image extensions DEFAULT: JPG JPEG GIF PNG | |
| Inputfield | string | May be 'on', 'off', or 'zoom' DEFAULT: on | |
| Inputfield | string | Default grid mode in admin, one of "grid", "left" or "list" DEFAULT: grid | |
| Inputfield | int | Squared size of the admin thumbnails DEFAULT: 130 | |
| Inputfield | array | Options to pass along to the ImageSizer class. See /wire/config.php $imageSizerOptions for details. | |
| Inputfield | string | Space separated CSS classes for items rendered by this Inputfield. Generally you should append rather than replace. | |
| Inputfield | int string | Max height for uploaded images, larger will be sized down DEFAULT: '' | |
| Inputfield | bool int | Reject images that exceed max allowed size? DEFAULT: false | |
| Inputfield | float | Maximum number of megapixels for client-side resize, i.e. 1.7 is ~1600x1000, alt. to maxWidth/maxHeight . DEFAULT: 0 | |
| Inputfield | int string | Max width for uploaded images, larger will be sized down DEFAULT: '' | |
| Inputfield | int string | Min height for uploaded images, smaller will be refused DEFAULT: '' | |
| Inputfield | int string | Min width for uploaded images, smaller will be refused DEFAULT: '' | |
| Inputfield | array | Array of manually whitelisted extensions, for instance [ 'SVG' ] must be manually whitelisted if allowed. DEFAULT: [] | |
| Inputfield | int bool | Resize to max width/height at server? 1=Server-only, 0=Use client-side resize when possible . DEFAULT: 0 | |
| Inputfield | int bool | Whether or not the modal image editor is allowed for this field DEFAULT: true |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.269