I have uploaded some PDFs to the Media Library.

I cannot find a way to set the browser favicon for the PDF media files.

Where does WordPress get the favicon from?

Is there anyway to control the PDF Media file favicon?

  • There should not be a favicon for a PDF file, a favicon is generaly for the whole site. If you mean something else please explain. Sep 29, 2015 at 16:36
  • Ah, but there is in Google Chrome. Explanation: the "favicon" is the 16x16 graphic image that appears in the browser title tab.
    – tammy
    Sep 29, 2015 at 16:52
  • 1
    what I see is a site favicon and you don't even need to do anything as controlling it is part of version 4.3 Sep 29, 2015 at 18:06
  • 1
    it is the "site icon" under "site identity" in the cusromizer Sep 29, 2015 at 18:36
  • 1
    Then it is a browser bug, or what you request has no applicable standartd. favicon.ico is an old hack that was good for the old simple web, but it is not good any longer as web site structure become more complex and access to server files more restricted. The standard based replacement for it requires serving an HTML page which specifies in its meta what image to use for favicon (and this is what 4.3 does). The problem of course is that pdf is not html and therefor there is no way to specify a favicon specifically for a single PDF file. Sep 30, 2015 at 3:08

2 Answers 2


To summarize the discussion in the comments, the answer for the question as it is asked is that it is not possible. The web standards as they are right now do not have a facility to declare a favicon for PDF files, only for the whole domain via the favicon.ico file.

You can try to hack around it by

  1. set the favicon.ico at the root of the site to the icon you want to be associated with media files and use the wordpress 4.3 site icon feature to handle the icon for the html (which should have priority over the favicon.ico).

  2. server the media files from a different domain (for example a subdomain of the main site) and set there a favicon.ico that you want to be associated with the media files.


Well, I think you only need to modify the favicon.ico file in your WordPress root directory.

Previous answer:

I guess you want to change this icon (/wp-includes/images/media/document.png):


that shows up for PDF documents in the Media Library.

You could then use the wp_mime_type_icon filter to change the icon:

add_filter( 'wp_mime_type_icon', function( $icon, $mime, $post_id )
    if( 'application/pdf' === $mime && $post_id > 0 )
        $icon = 'http://example.tld/pdf.png'; // Modify this to your needs!

    return $icon;
}, 10, 3 ); 

But for favicons, you can check out my answer here.

  • No, that's not the favicon that appears in the browser for me @birgire. See my most recent comment back to MarkKaplun above.
    – tammy
    Sep 29, 2015 at 17:32
  • I just updated the answer, after reading your comment, please add all relevant info into the question itself, thanks @tammy
    – birgire
    Sep 29, 2015 at 17:33
  • Ah, good tip @birgire, I'll check into that and post back.
    – tammy
    Sep 29, 2015 at 17:34
  • Yes, it looks like that is what's happening. Do you know if there is any "clever" way of overriding that? The reason is that the site that shows the "wrong" desired-favicon is only one site in the many multisite networks I am running. So I do not want to alter the base favicon. I merely want to set a favicon for this particular MS network site. Is that do-able @birgire?
    – tammy
    Sep 29, 2015 at 17:38
  • 1
    setting favicon is actually a feature of 4.3 and should work on all types of servers Sep 29, 2015 at 18:07

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