Fields / Media

Read More: Fieldmanager_Media

Allow users to select an attachment via the Media popup.

  1. Example 1: Basic Media Field

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Media( array(
    		'name' => 'demo-media',
    	) );
    	$fm->add_meta_box( 'Media Field', array( 'post' ) );
    } );
  2. Example 2: Media Field Options

    This example illustrates four media-specific options: button_label, modal_title, modal_button_label, and preview_size. These options allow you to customize labels and UI elements to create a customized (and hopefully more intuitive) interface for your users.

    add_action( 'fm_post_post', function() {
    	$fm = new Fieldmanager_Media( array(
    		'name' => 'demo-media',
    		'button_label' => 'Add Icon',
    		'modal_title' => 'Select Icon',
    		'modal_button_label' => 'Use Image as Icon',
    		'preview_size' => 'icon',
    	) );
    	$fm->add_meta_box( 'Media Field', array( 'post' ) );
    } );