WP Manifestindependent plugin directory
manifest / developer / wp-media-upload-input

WP Media Uploader Input Field WP Registry grade A-. Low-severity findings · 1 findingWP RegistryLow-severity findings · 1 findingOpen the reportA-

WordPress Media Uploader Input Field

★ 3stars
1.0.5latest · 12 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/n-molham/wp-media-upload-input/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

WordPress Media Uploader Input Field

A way to reuse media uploader in WordPress 3.5 or greater which is very very helpful and faster from the old one, OOP with chaining

Usage

  • just place the plugin folder in you plugins directory and activate it
  • the class WP_Media_Uploader_Input will be available to use

Example

$input_settings = array ( 
        // input options
        'input_name' => 'image', // input name for back-end handling
        'input_id_name' => 'id', // item ID input field name
        'input_url_name' => 'url', // item URL input field name
        'multiple' => 'no', // select multiple items or not, "yes" or "no"
        'data_array' => true, // get id & url as an array or not
        'image_placeholder' => WP_MU_URL .'images/placeholder.png', // image placeholder URL
        'image_placeholder_width' => '70', // image width
        'image_placeholder_height' => '70', // image height
        'media_uploader_button_label' => __( 'Media Uploader' ), // Media Uploader button name
        'single_remove_button_label' => __( 'Remove' ), // remove all items button label if multiple
        'multiple_remove_button_label' => __( 'Remove All' ), // remove item label if not multiple
        // Media uploader options
        'frame_title' => __( 'Select an Image' ), // Media Upload frame title 
        'select_button_label' => __( 'Use Image' ), // select button label
        'remove_confirm_message' => __( 'Are you sure ?' ), // confirm message on removing item(s)
        'remove_confirm_yes' => __( 'Yes' ), // "Yes" answer label
        'remove_confirm_no' => __( 'No' ), // "No" answer label
        'file_type' => 'image', // file type of items visible on Media Uploader window open
);
// initial input with settings
$input = new WP_Media_Uploader_Input( $input_settings );

// or set settings later
$input->set_options( $input_settings );

// or set a single option 
$input->set_option( 'option_name', 'option_value' );

// input value
$input->set_value( array ( 
        'id' => 246, 
        'url' => 'http://opensource.org/trademarks/opensource/OSI-logo-300x352.png' 
    ) 
);

// "output_input" with true passed will echo the layout and if false passed ( Default ) it will return HTML string
$input->output_input( true ); 

the code is highly customizable through filter hooks and jQuery events

Output Result

Live Preview

  • Download the plugin.
  • and define this constant WP_MU_TEST_MODE in your wp-config.php file.
  • and go to Dashboard > Settings > Media
// wp-config.php

// test input field enabled
define( 'WP_MU_TEST_MODE', true );

/* That's all, stop editing! Happy blogging. */

WP Hooks

Note : remember to user those filters before creating an instance

  • wpmuif_input_value
    • parameters: $value
    • The input default ( initial ) value
  • wpmuif_input_args
    • parameters: $settings
    • The input settings options parsed with default values
  • wpmuif_input_field
    • parameters: $output , $input_instance
    • The input HTML layout to display

Example:

add_filter( 'wpmuif_input_field', function( $output ) {
    return '<div class="media-input-wrapper">'. $output .'</div>';
} );

jQuery Events

Note: remember to listen for those events on the body element

  • wpmuif_media_frame_opened
    • parameters: file_frame , pre_selection
    • Passes the File ( Media ) frame instance and the items to be selected by default
  • wpmuif_selected_items
    • parameters: file_frame , selected
    • Passes the File ( Media ) frame instance and the selected items by the user

Example:

$( 'body' ).on( 'wpmuif_media_frame_opened', function( event, file_frame, pre_selection ) {
    console.log( file_frame, pre_selection );
} );

Contact if there are any problems

Hope you find it helpful :)

License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html

Releases

2 releases.

Tag
Published
1.0.5 latest
Apr 27, 2014 12 years ago
1.0
Apr 25, 2014 12 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A- grade

Security

WP Media Uploader Input Field 2.0 · audited by WP Registry

Low-severity findings only.

1 low
Audited release
2.0
Findings
1
Worst severity
low
Content hash
7e42748b434c7109ceace11f…

Findings

  • low Plugin header version does not match package slug

    version_mismatch

    Directory/slug is wp-media-upload-input-1.0.5 but the plugin header Version is 2.0, creating update/inventory confusion.

    wp-media-upload-input.php:1-15

    Recommendation

    Align header Version with the distributed package version.

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.