What it does
A plain file field sends whatever image the visitor picks. Universal Form Cropper adds a box to the form instead: the visitor drops an image in (or clicks to browse), moves it into place inside a square frame and adjusts the zoom, with a live preview.
When the visitor presses Save, the original image is uploaded to a temporary folder, cropped and resized on the server to a fixed square size, and saved in a final folder. The temporary copy is then deleted. The final image URL is written into a field of the form, so when the form is submitted, that field contains the link to the image, not the image itself. After saving, the visitor can reopen the crop or remove the image.
It is meant for any form, from Contact Form 7, WPForms or Gravity Forms to plain HTML. It has no code for any particular form plugin and works on the form's HTML, so two things decide whether a form keeps the URL: the shortcode must be rendered inside the form, and the form must process a field with the cropper's name (see The shortcode).
- Shortcode
- Server-side crop
- Square output
- JPG · PNG · WebP
- No jQuery
Install
- Download the ZIP.
- In WordPress go to Plugins → Add Plugin (called Add New Plugin or Add New in older versions), click Upload Plugin, choose the ZIP, click Install Now, then Activate Plugin.
- Open Settings → Universal Form Cropper. If the form is for visitors who are not logged in, or for users without the
upload_filescapability, turn on Allow guest uploads. - Put the shortcode inside your form.
The shortcode
[universal_form_cropper field="cropped_image" label="Upload photo"]
Attributes[universal_
- field
- Name of the form field that receives the image URL. Only letters a–z and A–Z, numbers,
_and-. Anything else falls back to the default,cropped_image. - label
- Text shown above the upload box. Default: “Upload photo”.
- key (optional)
- A positive whole number that turns the name into
field[key]. For examplekey="2"givescropped_image[2]. Use it when one form has more than one cropper, or to match a field named likeitem_meta[152](field="item_meta" key="152").
The shortcode must sit inside a <form>. If it doesn't, the box shows the message
“Universal Form Cropper must be placed inside a <form>.” It also has to be rendered as HTML there: if the page shows the shortcode as plain text
instead of the upload box, whatever prints the form is not running shortcodes in that spot.
If the form already has an input with exactly that name (hidden or not), the plugin writes the URL into it. If not, it adds a hidden input to the form, which a plain HTML form sends like any other field. With a form builder, create one of the builder's own fields (usually a hidden field) with exactly the same name, because a builder may ignore inputs it did not create.
Example: Contact Form 7
In the form template:
[universal_form_cropper field="cropped_image" label="Your photo"][hidden cropped_image]
In the Mail tab, add the mail-tag [cropped_image]. The email you receive will contain the URL of the cropped image.
Contact Form 7 does not run other plugins' shortcodes inside its form template by default. If the form shows [universal_form_cropper …] as plain text instead of the upload box,
add this line to your theme's functions.php (or a small custom plugin): add_filter( 'wpcf7_form_elements', 'do_shortcode' );
For a plain HTML form, the shortcode alone is enough, because the plugin adds the hidden input itself. Any other form builder needs the same two things as Contact Form 7:
it has to render the shortcode inside the form, and one of its fields has to carry exactly the name set by field (or field[key]).
Settings
All options live in Settings → Universal Form Cropper. A “Reset to defaults” button restores them without touching uploaded files.
Settingdefault
- Allow guest uploads
- Off. Only logged-in users with the
upload_filescapability can upload. Everyone else sees “Please sign in to upload an image.” or “You don't have permission to upload images.”, and saving fails withE_LOGIN_REQUIREDorE_FORBIDDEN. Turn it on for public forms: then anyone who can open the page can upload, within the rate limits. - Max upload size
- 2 MB (0.25 to 20 MB). Allowed types: JPG, PNG and WebP only. The browser checks the file first and the server checks it again.
- Output size
- 600 × 600 px, the size of the final square image (64 to 2000 px). The final file keeps the uploaded format.
- Minimum crop size
- 100 px (32 to 2000), measured on the original image. Smaller crops are rejected with
E_CROP_TOO_SMALL, so a very small image or a lot of zoom can fail. - Token lifetime
- 600 seconds (60 to 3600): how long the signed upload token stays valid. On Save, the widget fetches a new token if the current one is about to expire.
- Rate limits
- Per IP address: 60 token requests, 20 uploads and 20 final crops. A counter clears one window (1 hour) after the last request it counted. The window and every limit are adjustable.
- Temp retention
- 24 hours (up to 168; 0 turns cleanup off). An hourly job deletes temporary files older than this, such as uploads that never reached the final step. Final images are never deleted automatically.
- Widget UI
- Crop box size (250 px), preview size (160 px) and zoom minimum, maximum and step (1×, 3× and 0.01).
- Enable event logging
- Off. When on, events go to
logs/events.login the plugin's upload folder, rotated at 5 MB with the last 5 rotated files kept. IP addresses are stored only as hashes. Use it for debugging.
How it stays safe
- Secure by default. Guest uploads are off until you allow them.
- Every request is checked. Each one carries a WordPress nonce, and the upload and crop steps also need a short-lived signed token (10 minutes by default) tied to the visitor's IP address and browser.
- Strict file checks. Size limit, an allow-list of JPG, PNG and WebP, and a second type check on the uploaded file. Files get random names.
- The server makes the final image. The browser only sends crop coordinates. The server enforces the minimum crop size, takes the output size from your settings (not from the browser) and applies the photo's EXIF rotation first, so the crop matches what the visitor saw.
- Protected folders. The plugin writes
.htaccess(Apache) andweb.config(IIS) rules: temporary files and logs are closed to web visitors, and the image folders block script files and directory listing. Nginx ignores these files, so on Nginx add matching rules yourself. - Rate limiting per IP for tokens, uploads and final crops.
- Public links with random names. Anyone who has the URL of a final image can open it.
- Uninstall keeps your images. Deleting the plugin removes its settings and its scheduled cleanup. The
universal-form-cropperupload folder stays, so images your forms already sent keep working.
For developers
ufc_allow_guest_uploadsfilter: allow or block guest uploads in code. It receives the value of the setting.ufc_upload_capabilityfilter: change the capability needed to upload and crop (defaultupload_files).ufc_enable_loggingfilter turns logging on or off. DefiningUFC_DISABLE_LOGGINGastrueinwp-config.phpturns it off whatever the setting or filter says.- Requests go to
admin-ajax.phpwith the actionsufc_get_token,ufc_upload_tmpandufc_make_final. - Files are stored in the uploads folder (usually
wp-content/) underuploads/ universal-form-cropper/ tmp/,final/andlogs/. - The IP address used for rate limits and tokens comes from
REMOTE_ADDRonly. Behind a proxy or CDN that does not pass the visitor's IP to PHP, all visitors share the same rate-limit counters. - CSS and JavaScript load only on pages where the shortcode is used. The script is plain JavaScript with no dependencies.
Questions
Does the form send the image file?
No. It sends the URL of the cropped image stored on your site.
Visitors see “Please sign in to upload an image.” or E_LOGIN_REQUIRED. Why?
Guest uploads are off by default. Turn on Allow guest uploads in the settings.
Can I have two croppers in one form?
Yes. Give each one a different field, or the same field with different key values.
Will the cropped images be deleted?
No. Only temporary files are cleaned up. Final images stay until you remove them, including images saved in forms that were never sent. The trash icon in the form only clears the field; the file stays on the server.
Saving fails with an error code. What does it mean?
The line under the box shows “Failed:” followed by a code. The common ones:
Codemeaning
- E_LOGIN_REQUIRED
- Not logged in, and guest uploads are off.
- E_FORBIDDEN
- Logged in without the required capability, and guest uploads are off.
- E_CSRF
- The security nonce printed in the page failed the check, for example because a page cache served an old copy. If a cache is the cause, exclude the form page from it.
- E_RATE_LIMIT
- This IP address reached one of the rate limits.
- E_TOKEN_IP, E_TOKEN_UA, E_TOKEN_EXPIRED
- The visitor's IP address or browser changed since the page loaded, or the token expired. Reloading the page gets a new token.
- E_SIZE, E_MIME, E_UPLOAD_HANDLE
- The file is empty or over the size limit, is not a real JPG, PNG or WebP, or WordPress could not store it.
- E_UPLOAD
- PHP rejected the upload, for example a file over the server's PHP upload limit.
- E_CROP_TOO_SMALL
- The crop is smaller than the minimum crop size.
- E_EDITOR
- The server's image library cannot open the file. For WebP, GD or Imagick needs WebP support.