Posterous theme by Cory Watilo

Follow-up: Just as a feared (UPDATED)

I had a feeling that this would happen.

Media_httpiimgurcomlg_hcsmv

I thought I had a great idea here, and while it works if the current user is an author or higher on both sites, if the user only exists on the current site you get the message above when attempting to insert an image into the post. Now, it can be solved just by granting the current user access to the ‘media site’, but then that would also allow them to create, edit, and delete all media that exists in the ‘media site’ library. That’s no good.

While searching through the WordPress Codex I came across the upload_files user capability which is required to do ANYTHING with the media library. I thought that I could create a new user role that only allowed the user to access the media library. Unfortunately, upload_files is an all-or-nothing deal. Either the user has full rights to the media library or none at all.

If only a more granular control was available for this purpose.

Do you have a solution?


UPDATE

It seems that I was a little off about the all-or-nothing nature of the upload_files user capability. The ability to delete items in the media library is handled by a different capability. That’s the good news.

Now to figure out how to bar regular users from uploading to the ‘media site’…

Sharing media libraries across network sites in WordPress

Media_httpiimgurcom6h_awvxb

This is part of a larger project I’m developing at work.

The ultimate goal is to have a central blog where the department can serve up sanctioned images, video, and audio for students to use on their portfolios – also hosted in the same WordPress multisite network. After realizing that a (good) solution does not yet exist, I set out to create my own.

The first hurdle was to create a new tab in the Upload/Insert media page. This task was made easy by a great tutorial here.

The second and most difficult hurdle was solved by looking through the core code. I was looking for an existing function that handled the entire functionality of the media library. Eventually I found it in wp-admin/includes/media.php on line 822. The function is called media_upload_library().

Now for the last step. Plugging media_upload_library() into my code will only create a duplicate media library for the blog I am currently editing. To load a library from a different blog I need one last function. Before calling media_upload_library(), I call up another useful core WP function switch_to_blog($int) where $int is the blog ID number. This number can be found in the WP database.

I haven’t yet had a chance to thoroughly test this code. I’ve only tested this on sites where I am an admin so I’m sure I will run into trouble when I test it as a low-level user. If you have any suggestions, please let me know.

Here’s the code so far:

// Add filter that inserts our new tab
function nsm_menu($tabs) {
  $newtab = array('shared_media' => __('Network Shared Media', 'networksharedmedia'));
  return array_merge($tabs, $newtab);
}
add_filter('media_upload_tabs', 'nsm_menu');

// Load media_nsm_process() into the existing iframe
function nsm_menu_handle() {
  return wp_iframe('media_nsm_process');
}
add_action('media_upload_shared_media', 'nsm_menu_handle');

/*
 * media_nsm_process() contains the code for what you want to display. This function MUST start with the word 'media' in order
 * for the proper CSS to load.
 *
 * First, we switch to the blog containing all of the media. This is called up by the blog # found in the database.
 *
 * Then we call media_upload_library() which contains all of the code needed to show the library, select media sizes, and
 * insert into the post.
 */
 function media_nsm_process() {
   switch_to_blog(3);
   media_upload_library();
 }

Take a look at the follow-up post.

My future kids are SO going to have a zipline over a pit of giant chainsaws!

Sometimes, of course, their mastery fails, and falls are the common form of playground injury. But these rarely cause permanent damage, either physically or emotionally. While some psychologists — and many parents — have worried that a child who suffered a bad fall would develop a fear of heights, studies have shown the opposite pattern: A child who’s hurt in a fall before the age of 9 is less likely as a teenager to have a fear of heights.

By gradually exposing themselves to more and more dangers on the playground, children are using the same habituation techniques developed by therapists to help adults conquer phobias, according to Dr. Sandseter and a fellow psychologist, Leif Kennair, of the Norwegian University for Science and Technology.

via nytimes.com

What's that, little Timmy? Your arm got sawed off?

Rub some dirt in it and ride the zipline again!

A 'Dear John' Letter to Excel

Dear Excel,

Over the past several years you and I have become great friends. I thought that we would share everything with each other; well until you wouldn't share my documents with my friends, family, and coworkers.

I have to admit something:
I've been with another spreadsheet program. It's name is Google Docs. It's given me great satisfaction for the past year and a half. It has no problem sharing with all of the people I interact with, following me wherever I feel like working, and being easy to work with.

But you always had that one characteristic that kept me from leaving you completely: Pivot Tables.

Your robust pivot tables enabled me to understand my data with great ease; but alas, Google Docs recognized my frustration of being split between two people and took aim at my sadness.

Today Google Docs completed it's package and I cant turn away from it.

So...I'm writing this letter to let you know that we should go our separate ways. I know you can make an enterprise very happy, but for me as an individual I cant be satisfied by you.

It's not you, it's me.