• Resolved Fred Chapman

    (@fwchapman)


    Hi John,

    May I make a feature request? I noticed something that happens when I use the Media Author plugin in the Add Media screen for a page or post. It selects the first user in alphabetical order (usually the Administrator) as the default author. When I save changes in the Add Media screen, it ends up changing the media author, unless I manually select the current media author before saving.

    Could you modify the plugin so that it defaults to the current media author instead of defaulting to the Admin? That would be a huge help!

    Thanks,

    Fred

    http://wordpress.org/extend/plugins/media-author/

Viewing 12 replies - 1 through 12 (of 12 total)
  • You got a point here.

    The normal Edit Media screen gets the correct attachment_id as $_GET['attachment_id'] for the plugin.

    The Add Media screen for a page or post only gets the current post_id of the page or post as $_GET['post_id'] and has no information about the actual attachment owner.

    So either we could add a patch which sets the current post author as attachment author (as you propose, see patch #1) or the “Media Author” select should be removed (not included) in the Add Media screen popup (maybe better, see patch #2).

    Locate this in file media_author.php:

    /*
     * This is the usable method, as of WordPress 2.9.0
     */
    function media_author_plugin_dropdown_2($args) {
    	$author_id = get_post($_GET['attachment_id'])->post_author;
    ...

    For patch #1 replace with this:

    function media_author_plugin_dropdown_2($args) {
    	if ( isset ( $_GET['attachment_id'] ) ) {
    		$post_id = $_GET['attachment_id'];
    	} else if ( isset ( $_GET['post_id'] ) ) {
    		$post_id = $_GET['post_id'];
    	} else {
    		return $args;
    	}
    	$author_id = get_post( $post_id )->post_author;
    ...

    For patch #2 replace with this:

    function media_author_plugin_dropdown_2($args) {
    	if ( isset ( $_GET['attachment_id'] ) ) {
    		$post_id = $_GET['attachment_id'];
    	} else {
    		return $args;
    	}
    	$author_id = get_post( $post_id )->post_author;
    ...

    Thread Starter Fred Chapman

    (@fwchapman)

    Ov3rfly:

    Thank you so much for your speedy and detailed reply!

    I agree that patch #2 is probably the better choice. I don’t need to change the media author when I’m attaching an image to a page or post, and I never expected to be able to do that in the first place. That’s why I was so surprised when I finally figured out that this plugin was changing the media author in the Add Media screen.

    John:

    Can you apply patch #2 to remove the Media Author select field from the Add Media screen or would you prefer to change the plugin so that Add Media behaves the same way as Edit Media? I’m okay with either approach. I just don’t want to change the media author by accident.

    Thanks again,

    Fred

    Found a third patch, which is the best so far, it shows the correct attachment owners also in the Add Media screen.

    Locate this in file media_author.php:

    /*
     * This is the usable method, as of WordPress 2.9.0
     */
    function media_author_plugin_dropdown_2($args) {
    	$author_id = get_post($_GET['attachment_id'])->post_author;
    ...

    For patch #3 replace with this, note the added “$post = false” arg:

    function media_author_plugin_dropdown_2( $args, $post = false ) {
    	if ( isset ( $_GET['attachment_id'] ) ) {
    		$post_id = $_GET['attachment_id'];
    	} else if ( $post ) {
    		$post_id = $post->ID;
    	} else {
    		return $args;
    	}
    	$author_id = get_post( $post_id )->post_author;
    ...

    Also locate this at the end of file media_author.php:

    add_filter('attachment_fields_to_edit', 'media_author_plugin_dropdown_2', 5);

    For patch #3 replace with this, note the added “, 2” at the end:

    add_filter('attachment_fields_to_edit', 'media_author_plugin_dropdown_2', 5, 2);
    Plugin Author John Luetke

    (@johnl1479)

    Thanks Ov3rfly, patch #3 looks promising. Can you submit it as a diff file against the plugin (since it’s an actual feature request that you’ve coded)? http://plugins.trac.wordpress.org/newticket

    Type: enhancement
    Component: not-listed
    Keywords: media-author
    Owner: johnl1479

    I will try and get it updated tonight or tomorrow

    @john: Feel free to add the change yourself. Won’t have time for that today.

    I actually consider it as a bugfix as get_post($_GET['attachment_id'])->post_author returned an invalid value in Add Media screen before.

    @john: Submitted a ticket, hope the unix diff will help.

    http://plugins.trac.wordpress.org/ticket/1590

    Thread Starter Fred Chapman

    (@fwchapman)

    John, did you ever get a chance to apply the patch provided by Ov3rfly? I really like your plugin, but I have to temporarily disable it until the patch is installed. -Fred

    Plugin Author John Luetke

    (@johnl1479)

    It would appear that I did not :$

    I’ll try to get it updated in a few hours

    Plugin Author John Luetke

    (@johnl1479)

    This might take a little longer than expected. It looks like WP 3.5 introduced a breaking change

    Plugin Author John Luetke

    (@johnl1479)

    Hi all,

    Media Author has been updated to version 1.0.4. This includes Ov3rfly’s patch and WP 3.5 compatibility.

    Hello John,

    Before I begin, I would like to congratulate you for your work! Recently, I started using the WordPress 3.5 where I’ve added the Media Author 1.0.4. Unfortunately, I have problems in changing the albums’ authors. For example, if I have an album with 50 photos and I want to change the author, I can’t change it unless I take every single photo, it won’t let me to do it at once. And it’s taking me too much time. Could you please tell me if there is a much easier way to do these changes? I would much appreciated!

    Thank you!

    Onut

    Thread Starter Fred Chapman

    (@fwchapman)

    John, thank you so much for updating your Media Author plugin! I look forward to giving it a try.

    Ov3rfly, thank you so much writing a patch for this plugin. I appreciate your help.

    Fred

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: Media Author] FEATURE REQUEST: Default to current author.’ is closed to new replies.