Adding a column with the URL of the media file
If you often need to take the addresses of images to insert into a metabox or custom field, then creating a separate column with the address of the picture will be most welcome for you. Just add the following code snippet to your theme's functions.php file.
1 2 3 4 5 6 7 8 9 |
function muc_column( $cols ) { $cols["media_url"] = "URL"; return $cols; } function muc_value( $column_name, $id ) { if ( $column_name == "media_url" ) echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="'. wp_get_attachment_url( $id ). '" />'; } add_filter( 'manage_media_columns', 'muc_column' ); add_action( 'manage_media_custom_column', 'muc_value', 10, 2 ); |
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.