Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

when show/edit an image/file, on the right side of the image/file, there are some text info-- File name, File Type, Upload date, Demention... How to modify those text?

share|improve this question
    
what you mean by modify? alter them? or add new ones, delete them? I'm not new in attachment field so maybe i can post answer but i need to know what exacly you want to do. and exacly what fields if you want to edit them. –  Tommixoft Jun 4 '12 at 8:58
    
@Tommix , it's not fields, it's the area on the top left of the edit image screen. currently it's File Nmae, File Type, Uplaod date. I want to change it to Title, Author, Source, License. –  Jenny Jun 4 '12 at 9:24
    
So you want to ADD new fields,labels, not change. If you only want change words you can do that via translating them but it's stupid you need add new fields, labels. Wait i'll show you how. As i understood you want to asign value to those fields by yourself dynamicly so it shouldn't be editable yes? –  Tommixoft Jun 4 '12 at 13:30

1 Answer 1

up vote 2 down vote accepted

Add this to functions.php file.

  function image_attachment_field($form_fields, $post) {  
if( substr($post->post_mime_type, 0, 5) == 'image' ){  
    $user = new WP_User( $post->post_author );
    $form_fields["author"]["input"] = "html"; 
    $form_fields["author"]["html"] = '<p><strong>Author:</strong> '.$user->display_name.'</p>';
    $form_fields["license"]["input"] = "html"; 
    $form_fields["license"]["html"] = '<p><strong>License:</strong> GPL</p>';
    $form_fields["source"]["input"] = "html"; 
    $form_fields["source"]["html"] = '<p><strong>Source:</strong> BNS</p>';

}
    return $form_fields;  
}  

add_filter("attachment_fields_to_edit", "image_attachment_field", null, 2); 

This will ONLY add info, cause you did not said you want user be able to edit it. So you have to edit this code to asign values.

Also there is no easy way of putting these labels in top. So don't ask me how, it just did not possible to do without editing WP code or adding javascript to change possitions of elements, but this also is not very wise.

share|improve this answer
    
That's exactly what I want-- provide media info and not allow editing. Thanks! It'd be better if can remove the file type / file name on the right side of picture, but since you said it's not easy without modify core, I will live with that. –  Jenny Jun 5 '12 at 10:07
    
yep - you can't hide them without editing core or withouth useing jQuery to hide those elements, but in both cases - custom labels still be putted lower then those in top so...no easy way to do this if you still want to use WP updates. –  Tommixoft Jun 5 '12 at 12:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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