Skip to content
Block Controls

File

File control lets you upload and select files using the WordPress Media Library. The control stores file information as an array.

File Control

Control Settings

  • Allowed Mime Types (allowed_mime_types) - the file types the media picker accepts. Empty by default, and an empty list allows every type WordPress allows

The field is a multi-select over the file types WordPress allows uploading, so the choices are extension groups such as jpg|jpeg|jpe, png and mp4|m4v rather than free text.

Saved Data

The control saves the following file information:

NameDescription
idUnique ID of uploaded file
urlURL to access the file
altOptional alt attribute used in <img> tags
titleAttachment title
captionOptional caption
linkLink to file

Usage

PHP
<audio src="<?php echo esc_url( $attributes['control_name']['url'] ); ?>" controls>
</audio>
Handlebars
<audio src="{{control_name.url}}" controls>
</audio>
Post Meta
<?php
$file = get_lzb_meta( 'control_meta_name' );
?>
<audio src="<?php echo esc_url( $file['url'] ); ?>" controls>
</audio>

The control uses the native WordPress Media Library for file uploads and selection.

Was this article helpful?

Copyright © 2026 Lazy Blocks.