Small Extension for the Media-Library


Small changes can sometimes work wonders. If you use the library and use a lot of pictures in the posts, the following small link in the library will surely help you. Thus, images can be easily reused. A link will be created so you can access the image directly and there is no need to upload the image again to your new post. Further information can be found in this post.

A similar solution is the Plugin Post2Media, which provides a link within the Thickbox to the attachments.
The following code should be used as a Plugin; alternative you can use the functions.php of your theme.

medialibrary3

function upload_columns($columns) {
	unset($columns['parent']);
	$columns['better_parent'] = __( 'Parent' );
	return $columns;
}

function media_custom_columns($column_name, $id) {
	$post = get_post($id);
	
	if ( $column_name != 'better_parent' )
		return;
	
	if ( $post->post_parent > 0 ) {
		if ( get_post($post->post_parent) )
			$title = _draft_or_post_title($post->post_parent);
		?>
		<strong>
			<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a>
		</strong>, <?php echo get_the_time( get_option('date_format') ); ?>
		<br />
		<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e( 'Re-', 'textdomain' ); _e('Attach'); ?></a>
		<?php
	} else {
		_e( '(Unattached)' ); ?>
		<br />
		<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Attach'); ?></a>
	<?php
	}
}
add_filter( 'manage_upload_columns', 'upload_columns' );
add_action( 'manage_media_custom_column' , 'media_custom_columns', 0, 2 );

Comments are closed.

5 comments

  1. Philipp

    Halleluja! Danke!!! Gerade bei Seiten mit WPML ist das immer die Hölle gewesen.

  2. Philipp

    Okay, sorry. Ich verstehe es nicht ganz: Es soll doch möglich sein, eine 1:n Verknüpfung zwischen Bildern und Posts / Seiten zu erstellen, oder? Bei mir in der Mediathek wird der Reattach - Button nicht angezeigt. Strange.

  3. Frank

    eine 1:n bekommst du mit dem Plugin Post2Media, welches dort genannt ist.

  4. Rhonda Klenk

    I really like what you blog about here,very insightful and intelligent. One thing though, I'm running Chrome in Fedora and parts of your site structure are a little off. I realize it really is not really the typical setup, however it is always a thing to keep an eye on. I hope this helps and keep up the quality publishing.

    http://thebestwordpressplugins.com

One pingback

  1. Невеличке розширення для Медіа-бібліотеки » Хаки для Wordpress » Український Wordpress