3

I would like to rename the "Add Media" button (just above the post editor interface) to be "Add Images". I can't seem to find the appropriate filter for this. There seems to be a filter that has now been deprecated but I can't figure out what the new method is. The legacy filter was media_buttons_context.

  • 1
    I'm curious, why? You're aware it's possible to add video, sound, PDFs, etc? – Tom J Nowell Apr 8 '13 at 15:49
8

The button text being a translatable string, you can make use of the gettext filter:

function wpse95025_rename_media_button( $translation, $text ) {
    if( is_admin() && 'Add Media' === $text ) {
        return 'Add Images';
    }
    return $translation;
}
add_filter( 'gettext', wpse95025_rename_media_button, 10, 2 );

For the sake of completeness:
Of course, you can also keep the new string translatable.

function wpse95025_rename_media_button( $translation, $text ) {
    if( is_admin() && 'Add Media' === $text ) {
        return __( 'Add Images', 'your-text-domain' );
    }
    return $translation;
}
add_filter( 'gettext', wpse95025_rename_media_button, 10, 2 );
  • Thanks very much. I wasn't familiar with that filter. Appreciate the response. – Peter Willis III Apr 8 '13 at 15:39
  • 1
    If this solved you're issue, @Peter (which I am confident it did), be so kind as to tick the checkmark to the left of the answer to mark your question as answered, such that others can tell that it is in the future. – Johannes Pille Apr 8 '13 at 15:44

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.