Question

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?

Était-ce utile?

La solution

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.

Autres conseils

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):

icon

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange
scroll top