Image and File
3 min read
Both types store one media library item as its attachment ID. The file itself stays in the media library; the field only remembers which one.
Image | File | |
|---|---|---|
Type id |
|
|
Column |
|
|
Accepts | Image attachments only | Any attachment |
| attachment ID ( | attachment ID ( |
Prints | an | a link to the file |
Safe type change | to File | to Image |
Need several images? The Gallery type (Pro) stores a list; see Pro field types.
Type settings
Setting | Type | Default | Effect |
|---|---|---|---|
Image size on the site | Image only |
| The registered image size printed on the site. The list contains every size your theme and WordPress register, plus |
Allowed file types | Image and File | empty | Comma-separated extensions the field accepts, for example |
When types are limited, the media library dialog only offers matching files, and the empty button shows the allowed extensions (for example JPG, PNG). An attachment is accepted when its extension or its MIME type matches.
Edit screen
Image | File | |
|---|---|---|
Empty | a large button labelled Select image (with the allowed extensions) | a large button labelled Select file (with the allowed extensions) |
Filled | thumbnail and file name, Replace image, Remove | file icon, title, file name and size, Replace file, Remove |
Media dialog title | Choose an image | Choose a file |
Clicking the button opens the media library, where editors can also upload a new file. A file that does not match the allowed types is refused with a message under the field.
In front-end forms (Pro) the field becomes a plain file upload; the form uploads the file when it is submitted and shows a Remove checkbox for the current file.
What is accepted when saving
The value must be an existing attachment ID of the right kind and (when limited) an allowed type. Anything else clears the field.
Input | Image (types | File (types |
|---|---|---|
Image attachment | saved | refused (not |
A text attachment | refused (not an image) | saved |
| empty | empty |
| empty | empty |
Template usage
$id = wpmcf_get_field( 'team', 'photo' ); // 712 (int) or null
if ( $id ) {
echo wp_get_attachment_image( $id, 'large', false, [ 'class' => 'team-photo' ] );
$url = wp_get_attachment_image_url( $id, 'full' ); // "http://example.com/wp-content/uploads/2026/10/photo.jpg"
}
wpmcf_the_field( 'team', 'photo' );
// <span class="wpmcf-field-value"><img width="300" height="200" src="…/photo-300x200.jpg"
// class="attachment-medium size-medium" alt="…" decoding="async" srcset="…" /></span>[wpmcf_field group="team" field="photo" wrap="false"]
[wpmcf_field group="docs" field="brochure" wrap="false"]
→ <a href="http://example.com/wp-content/uploads/2026/10/brochure.pdf">Product brochure</a>- The Image output is WordPress's own
wp_get_attachment_image(), sosrcset,sizes, lazy loading and the attachment's Alternative Text are included. - The File output is a link whose text is the attachment Title (or the file name when the title is empty).
- If the attachment was deleted from the media library, the stored ID remains but nothing is printed (
wpmcf_get_field()still returns the old ID). Check withwp_get_attachment_url( $id )if that matters. - An Image field holding a non-image, or a File field whose attachment was deleted, prints nothing.
The WPM Field block and the WPM Fields block binding can use an Image field as an image source (see Blocks and block bindings).
Import
CSV imports accept a numeric attachment ID or a URL of a file in this site's media library; the URL is turned into the ID. Files that are not in the library are not downloaded.
Troubleshooting
- The image looks too small or too big. Change Image size on the site or print it yourself with a size from
wp_get_attachment_image(). - I cannot select an SVG or other file. WordPress must allow the file type for uploads, and the type must be in Allowed file types if you set one.
- The field shows nothing selected after I deleted the file. The attachment no longer exists; pick a new file and save.
- I need the file's URL, not a link. Use
wp_get_attachment_url( wpmcf_get_field(...) ).
Still stuck? Contact support