Media fields store a reference, not a picture. What you get back depends on the field’s Return Format, and how you render it depends on that choice.
What It Does
An image or file field holds an attachment ID, a URL, or an array. The ID is the most useful of the three, because WordPress can build a responsive, correctly sized image from it.
Before You Start
- Nexter Extension is active.
- A field group with values saved on a post.
- You know the field’s Field Name.
Render a Media Field
- Check the field’s Return Format in the builder.

- Read the value with
nxt_field_value().
- Guard against an empty or deleted attachment before rendering.
- For an image, let WordPress build the markup so it is responsive and sized properly. For a file, build the download link from the attachment.
Display the Value
Both shapes, with the guards that matter:
<?php
// Image, Return Format = ID
$id = nxt_field_value( 'hero' );
if ( $id && wp_get_attachment_url( $id ) ) {
echo wp_get_attachment_image( $id, 'large' );
}
// File, Return Format = ID
$file = nxt_field_value( 'brochure' );
if ( $file && wp_get_attachment_url( $file ) ) {
printf(
'<a href="%s" download>%s</a>',
esc_url( wp_get_attachment_url( $file ) ),
esc_html( get_the_title( $file ) )
);
}
Limitations
- Deleting the attachment from the media library leaves the ID stored. Always check it still resolves before rendering.
- Files in the media library are publicly reachable by URL. A file field is not a way to serve private documents.
- With Return Format set to URL you lose the alt text and the size variants, so
wp_get_attachment_image()is no longer available to you.
Troubleshooting
I get a number instead of an image
That is the attachment ID — the Return Format. Pass it to wp_get_attachment_image(), or change the format to URL.
The image renders but has no alt text
Alt text comes from the media library, not the field. Set it on the attachment and wp_get_attachment_image() will use it.










