0

When I open my media library and go to the detailed view i get the list of the pictures contaning this row:

enter image description here

Is there a way/plugin to change the "uploaded to" setting for one spesific picture? (My theme can generate slides and it takes all the pictures in one slide that have the same uploaded to value.)

  • 2
    can you give an example of what you're wanting the output to be? Are you wanting to just change the message in that column or something more specific? – Welcher Sep 25 '14 at 1:31
  • @Welcher Y for example from "Slideshow" to "Slideshow2" – kimliv Sep 25 '14 at 5:32
1

You'll need to do 2 things. First, filter the current media columns.

add_filter('manage_media_columns' , 'newMediaColumnNames');
function newMediaColumnNames( $columns ) {

    //remove the old column - optional
    unset( $columns['parent'] ); 

    //add a new one to take it's place
    $columns['new_uploaded_to'] = __('New Uploaded To');

    return $columns;
}

I was not able to find a way to edit the content for the pre-existing Uploaded To column so we remove the current one and replace it with our own, or just add a new column for the custom content - that's up to you.

The next step is to add the content for the new column:

add_action('manage_media_custom_column', 'newMediaColumnContent', 1, 2);

function newMediaColumnContent( $column_name, $id ){

    switch($column_name) {
        case 'new_uploaded_to':
            echo 'Custom Content Here';
         break;
    }
}

You'll need to add the logic to add the actual content you want to display where the echo 'Custom Content Here'; is. Whatever you echo out there will be displayed in the new column you created.

Hope this helps!

  • sorry I think there is a misunderstanding. If I upload a picture to a post it gets the flag from the post it is uploaded to in this case it got the flag "Slideshow" and now I want to edit this flag at a specific picture to example "Post2". Your code does something else as far as I understand it. – kimliv Sep 25 '14 at 22:10
  • Regardless of the flag you put on either the post or the attachment, you'll need to modify the columns to change the output. The code example does that - as I said you'll need to fill in the blanks as to what gets output. – Welcher Sep 26 '14 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.