How to replace default icon on “Add Media” button?

I want to use a different icon for Add Media button in the standard post editing form. What’s the best way of doing it?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

CSS is the way to go here.

Add a new CSS for admin using the admin_enqueue_scripts hook in your child theme functions.php (if you don’t have one, you’re doing something wrong)

function my_admin_enqueue_style() {
    wp_enqueue_style('my-css', get_stylesheet_directory_uri().'/css/my-admin.css', array(), '1.0.0');
}
add_action('admin_enqueue_scripts', 'my_admin_enqueue_style');

In your my-admin.css file

/* change the content to another Dashicon */
#wp-content-editor-tools .wp-media-buttons .add_media span.wp-media-buttons-icon::before {
    content: "f104";
}

/* or set a background-image instead (set content to "" in the rule before) */
#wp-content-editor-tools .wp-media-buttons .add_media span.wp-media-buttons-icon {
    background-image: url(../../wp-content/uploads/2017/10/my-image.png);
    background-position: center;
}

Available Dashicon icons here


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x