WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp enqueue media

Description

Enqueues all scripts, styles, settings, and templates necessary to use all media JavaScript APIs.

This function should be called from the 'admin_enqueue_scripts' action hook, or later.

Usage

<?php wp_enqueue_media$args ); ?>

Parameters

$args
(array) (optional) An array of arguments. Currently only one argument is used, 'post', which if passed will be used to set up the scripts for that post. Note: if you do not set this parameter, uploaded files will not be attached to a post.
Default: array()

Returns Values

This function does not return a value.

Examples

Default usage:

wp_enqueue_media();

Enqueue the media scripts for a particular post:

<?php

$args = array( 'post' => 34 );

wp_enqueue_media( $args );

?>

Notes

Change Log

Since: 3.5.0

Source File

wp_enqueue_media() is located in wp-includes/media.php

Related

Enqueue Styles

Enqueue Scripts

Front-End Hooks

Admin Hooks

Login Hooks

See also index of Function Reference and index of Template Tags.