In de volgende snippet laat ik zien hoe je makkelijk een URL kolom kan toevoegen aan de media bibliotheek zodat je snel kunt knippen en plakken.
// Function to add the column header
function media_url_column( $cols ) {
$cols["media_url"] = "URL";
return $cols;
}
// Function to add the cell body (the textfield)
function media_url_value( $column_name, $id = null ) {
// Are we rendering the "media_url" column?
if ( $column_name == "media_url" ) {
// Grab the URL of the attachment
$url = wp_get_attachment_url( $id );
// Render the textfield (with some jQuery autoselect magic)
echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="'. $url . '" />';
}
}
// Add filter and action
add_filter( 'manage_media_columns', 'media_url_column' );
add_action( 'manage_media_custom_column', 'media_url_value');
Plak de bovenstaande code in je functions.php. Wanneer je naar je media bibliotheek gaat zult je de URL zien verschijnen.