{"id":21354,"date":"2012-12-25T09:17:01","date_gmt":"2012-12-25T09:17:01","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/default-featured-image\/"},"modified":"2025-11-29T09:22:38","modified_gmt":"2025-11-29T09:22:38","slug":"default-featured-image","status":"publish","type":"plugin","link":"https:\/\/ur.wordpress.org\/plugins\/default-featured-image\/","author":8717017,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.8.2","stable_tag":"1.8.2","tested":"6.9.4","requires":"6.2","requires_php":"7.4","requires_plugins":null,"header_name":"Default featured image","header_author":"Jan Willem Oostendorp","header_description":"","assets_banners_color":"aec0bc","last_updated":"2025-11-29 09:22:38","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/wordpress.org\/extend\/plugins\/default-featured-image\/","header_author_uri":"https:\/\/janw.me\/","rating":4.9,"author_block_rating":0,"active_installs":70000,"downloads":542687,"num_ratings":67,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"0.9":{"tag":"0.9","author":"janw.oostendorp","date":"2012-12-26 21:12:16"},"1.0":{"tag":"1.0","author":"janw.oostendorp","date":"2013-02-04 19:59:17"},"1.1":{"tag":"1.1","author":"janw.oostendorp","date":"2014-01-28 19:10:03"},"1.2":{"tag":"1.2","author":"janw.oostendorp","date":"2014-02-02 14:42:02"},"1.3":{"tag":"1.3","author":"janw.oostendorp","date":"2014-12-19 15:51:51"},"1.4":{"tag":"1.4","author":"janw.oostendorp","date":"2016-03-23 08:48:09"},"1.5":{"tag":"1.5","author":"janw.oostendorp","date":"2016-04-15 18:02:55"},"1.6":{"tag":"1.6","author":"janw.oostendorp","date":"2017-07-04 12:46:19"},"1.6.1":{"tag":"1.6.1","author":"janw.oostendorp","date":"2020-04-17 09:02:43"},"1.6.2":{"tag":"1.6.2","author":"janw.oostendorp","date":"2020-05-25 19:17:42"},"1.6.3":{"tag":"1.6.3","author":"janw.oostendorp","date":"2020-06-22 08:04:03"},"1.6.4":{"tag":"1.6.4","author":"janw.oostendorp","date":"2021-01-05 08:01:38"},"1.7.1":{"tag":"1.7.1","author":"janw.oostendorp","date":"2022-03-08 14:57:43"},"1.7.2":{"tag":"1.7.2","author":"janw.oostendorp","date":"2022-05-19 19:38:24"},"1.7.2.1":{"tag":"1.7.2.1","author":"janw.oostendorp","date":"2023-04-05 17:08:54"},"1.7.3":{"tag":"1.7.3","author":"janw.oostendorp","date":"2024-12-09 09:30:07"},"1.7.4-beta":{"tag":"1.7.4-beta","author":"janw.oostendorp","date":"2024-02-16 14:48:33"},"1.8.0":{"tag":"1.8.0","author":"janw.oostendorp","date":"2025-01-08 17:00:45"},"1.8.1":{"tag":"1.8.1","author":"janw.oostendorp","date":"2025-03-30 13:02:50"},"1.8.2":{"tag":"1.8.2","author":"janw.oostendorp","date":"2025-11-29 09:22:38"},"BP2":{"tag":"BP2","author":"janw.oostendorp","date":"2024-01-15 19:18:18"},"blueprint":{"tag":"blueprint","author":"janw.oostendorp","date":"2024-01-15 18:52:54"}},"upgrade_notice":{"1.0":"<p>Update makes sure that the set image will show. Everywhere.<\/p>"},"ratings":{"1":1,"2":0,"3":1,"4":2,"5":63},"assets_icons":{"icon-128x128.jpg":{"filename":"icon-128x128.jpg","revision":1058491,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.jpg":{"filename":"icon-256x256.jpg","revision":1058491,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":1058491,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":1058491,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{"blueprint.json":{"filename":"blueprint.json","revision":3405704,"resolution":false,"location":"assets","locale":"","contents":"{\"$schema\":\"https:\\\/\\\/playground.wordpress.net\\\/blueprint-schema.json\",\"preferredVersions\":{\"php\":\"8.2\",\"wp\":\"latest\"},\"phpExtensionBundles\":[\"kitchen-sink\"],\"features\":{\"networking\":true},\"steps\":[{\"step\":\"login\",\"username\":\"admin\",\"password\":\"password\"},{\"step\":\"installPlugin\",\"options\":{\"activate\":true},\"pluginData\":{\"resource\":\"wordpress.org\\\/plugins\",\"slug\":\"default-featured-image\"}},{\"step\":\"installTheme\",\"themeZipFile\":{\"resource\":\"wordpress.org\\\/themes\",\"slug\":\"twentytwentytwo\"}},{\"step\":\"importFile\",\"file\":{\"resource\":\"url\",\"url\":\"https:\\\/\\\/raw.githubusercontent.com\\\/janw-me\\\/default-featured-image\\\/main\\\/.wordpress-org\\\/blueprints\\\/blueprint.xml\"}},{\"step\":\"writeFile\",\"path\":\"\\\/wordpress\\\/wp-content\\\/site-cleanup.php\",\"data\":{\"resource\":\"url\",\"url\":\"https:\\\/\\\/raw.githubusercontent.com\\\/janw-me\\\/default-featured-image\\\/main\\\/.wordpress-org\\\/blueprints\\\/site-cleanup.php\"}},{\"step\":\"runPHP\",\"code\":\"<?php require_once '\\\/wordpress\\\/wp-load.php'; require_once '\\\/wordpress\\\/wp-content\\\/site-cleanup.php';\"}]}"}},"all_blocks":[],"tagged_versions":["0.9","1.0","1.1","1.2","1.3","1.4","1.5","1.6","1.6.1","1.6.2","1.6.3","1.6.4","1.7.1","1.7.2","1.7.2.1","1.7.3","1.7.4-beta","1.8.0","1.8.1","1.8.2","BP2","blueprint"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2771497,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2771497,"resolution":"2","location":"assets","locale":""}},"screenshots":{"1":"The setting on the media page","2":"The media manager will start with the current selected image"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[133,84],"plugin_category":[50],"plugin_contributors":[79477],"plugin_business_model":[],"class_list":["post-21354","plugin","type-plugin","status-publish","hentry","plugin_tags-image","plugin_tags-media","plugin_category-media","plugin_contributors-janwoostendorp","plugin_committers-janwoostendorp"],"banners":{"banner":"https:\/\/ps.w.org\/default-featured-image\/assets\/banner-772x250.jpg?rev=1058491","banner_2x":"https:\/\/ps.w.org\/default-featured-image\/assets\/banner-1544x500.jpg?rev=1058491","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/default-featured-image\/assets\/icon-128x128.jpg?rev=1058491","icon_2x":"https:\/\/ps.w.org\/default-featured-image\/assets\/icon-256x256.jpg?rev=1058491","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/default-featured-image\/assets\/screenshot-1.png?rev=2771497","caption":"The setting on the media page"},{"src":"https:\/\/ps.w.org\/default-featured-image\/assets\/screenshot-2.png?rev=2771497","caption":"The media manager will start with the current selected image"}],"raw_content":"<!--section=description-->\n<p>Add a default featured image to the media settings page. This featured image will show up if no featured image is set. Simple as that.<\/p>\n\n<p>Take a look at <a href=\"http:\/\/wordpress.org\/extend\/plugins\/default-featured-image\/faq\/\">FAQ<\/a> for the basic questions.\nFeel free to contact me <a href=\"https:\/\/wordpress.org\/support\/plugin\/default-featured-image\/\">on the forum<\/a> or on the <a href=\"https:\/\/github.com\/janw-me\/default-featured-image\">github repository<\/a>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Unzip the folder to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Go to the settings-&gt;media page and select an image.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='my%20chosen%20featured%20image%20doesn%27t%20show%2C%20why%20isn%27t%20it%20working%3F'><h3>My chosen featured image doesn't show, why isn't it working?<\/h3><\/dt>\n<dd><p>This plugin works out of the box for most cases, but not always. If it doesn't work you can try the following things.<\/p>\n\n<ul>\n<li>Switch themes. Most of the time the theme does something weird.<\/li>\n<li>Are you using the Core WordPress functions to get the image? (see the FAQ below this one).<\/li>\n<li>Do normal feature images work?<\/li>\n<li>Might it be hidden via css? DFI images have an extra <code>default-featured-img<\/code> class added to them.<\/li>\n<\/ul>\n\n<p>Still having problems? I want to know if it fails, so <a href=\"http:\/\/wordpress.org\/support\/plugin\/default-featured-image\">contact me<\/a><\/p><\/dd>\n<dt id='which%20functions%20can%20i%20use%20to%20display%20the%20featured%20image%3F'><h3>Which functions can I use to display the featured image?<\/h3><\/dt>\n<dd><p>There are no new functions, all core WordPress functions can be used.<\/p>\n\n<ul>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/the_post_thumbnail\/\">the_post_thumbnail<\/a> \/ <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_post_thumbnail\/\">get_the_post_thumbnail<\/a> Display the image.<\/li>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/the_post_thumbnail_url\/\">the_post_thumbnail_url<\/a> \/ <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_post_thumbnail_url\/\">get_the_post_thumbnail_url<\/a> Get the url.<\/li>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/has_post_thumbnail\/\">has_post_thumbnail<\/a> If a DFI is set it will always return true.<\/li>\n<li><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_thumbnail_id\/\">get_post_thumbnail_id<\/a> will return the ID set on the post or the DFI.<\/li>\n<\/ul><\/dd>\n<dt id='can%20i%20set%20a%20different%20image%20for%20a%20custom%20post%20type%3F'><h3>Can I set a different image for a custom post type?<\/h3><\/dt>\n<dd><p>Yes, the following code will set a different image.<\/p>\n\n<pre><code>add_filter( 'dfi_thumbnail_id', 'dfi_posttype_book', 10, 2 );\nfunction dfi_posttype_book( $dfi_id, $post_id ) {\n    $post = get_post( $post_id );\n    if ( 'book' === $post-&gt;post_type ) {\n        return 31; \/\/ the image id for the book post type.\n    }\n\n    return $dfi_id; \/\/ the original featured image id.\n}\n<\/code><\/pre><\/dd>\n<dt id='can%20i%20set%20different%20images%20per%20category%3F'><h3>Can I set different images per category?<\/h3><\/dt>\n<dd><p>Yes, the following snippet will set different images based on the category.<\/p>\n\n<pre><code>add_filter( 'dfi_thumbnail_id', 'dfi_category', 10, 2 );\nfunction dfi_category( $dfi_id, $post_id ) {\n    \/\/ Set a different image for posts that have the 'cats' category set.\n    \/\/ This will trigger first, if multiple categories have been set.\n    if ( has_category( 'cats', $post_id ) ) {\n        return 7; \/\/ cats img id.\n    }\n    \/\/ Set a different image for posts that have the 'cats' category set.\n    if ( has_category( 'dogs', $post_id ) ) {\n        return 8; \/\/ dogs img id.\n    }\n\n    return $dfi_id; \/\/ the original featured image id.\n}\n<\/code><\/pre><\/dd>\n<dt id='can%20i%20change%20the%20html%20of%20the%20default%20featured%20image%3F'><h3>Can I change the HTML of the default featured image?<\/h3><\/dt>\n<dd><p>When a Default Featured Image is used it will already add an extra class <code>default-featured-img<\/code>.\nThis can be used for styling.<\/p>\n\n<p>If you need more you can change the whole HTML with the filter <code>dfi_thumbnail_html<\/code>.<\/p>\n\n<pre><code>add_filter( 'dfi_thumbnail_html', 'dfi_add_class', 10, 5 );\nfunction dfi_add_class( $html, $post_id, $default_thumbnail_id, $size, $attr ) {\n    \/\/ Add a class to the existing class list.\n    $attr['class'] .= ' my-class';\n\n    return wp_get_attachment_image( $default_thumbnail_id, $size, false, $attr );\n}\n<\/code><\/pre><\/dd>\n<dt id='can%20i%20exclude%20one%20page%20from%20having%20a%20default%20featured%20image%3F'><h3>Can I exclude one page from having a Default Featured Image?<\/h3><\/dt>\n<dd><p>The following code will exclude the post\/page with ID 23.<\/p>\n\n<pre><code>add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10, 2 );\nfunction dfi_skip_page( $dfi_id, $post_id ) {\n    if ( $post_id == 23 ) {\n        return 0; \/\/ invalid id.\n    }\n\n    return $dfi_id; \/\/ the original featured image id.\n}\n<\/code><\/pre><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.8.2<\/h4>\n\n<ul>\n<li>Fixed typo in uninstall script.<\/li>\n<\/ul>\n\n<h4>1.8.1<\/h4>\n\n<ul>\n<li>Small refactor, no code or feature changes.<\/li>\n<li>Removed wp.org assets from plugin zip.<\/li>\n<\/ul>\n\n<h4>1.8.0<\/h4>\n\n<ul>\n<li>Expose the DFI option via the rest API.<\/li>\n<\/ul>\n\n<h4>1.7.3<\/h4>\n\n<ul>\n<li>PHP 7.4 and WP 6.2 are now required. This is to use the new <a href=\"https:\/\/make.wordpress.org\/core\/2023\/03\/07\/introducing-the-html-api-in-wordpress-6-2\/\">WP_HTML_Tag_Processor<\/a> functions.<\/li>\n<li>Fixed a bug where classes were overridden.<\/li>\n<\/ul>\n\n<h4>1.7.2.1<\/h4>\n\n<ul>\n<li>Development is now done in git.<\/li>\n<\/ul>\n\n<h4>1.7.2<\/h4>\n\n<ul>\n<li>Added extra context to a translation as suggested by <a href=\"https:\/\/wordpress.org\/support\/topic\/i18n-issue-14\/\">Alex Lion<\/a><\/li>\n<\/ul>\n\n<h4>1.7.1<\/h4>\n\n<ul>\n<li>Fixed weird SVN deployment bug.<\/li>\n<\/ul>\n\n<h4>1.7.0<\/h4>\n\n<ul>\n<li>moved main class to it's own file.<\/li>\n<li>Added second class that can hold exceptions with other plugins<\/li>\n<li>The first exception is for WP User Frontend<\/li>\n<li>The second exception  is for WP All Import.<\/li>\n<\/ul>\n\n<h4>1.6.4<\/h4>\n\n<ul>\n<li><code>get_post_meta($post_id)<\/code> without specifying the meta_key didn't find the DFI. It will now even use an even deeper level and set it in the core cache.<\/li>\n<\/ul>\n\n<h4>1.6.3<\/h4>\n\n<ul>\n<li>Fixed plugin header which blocked installing it.<\/li>\n<\/ul>\n\n<h4>1.6.2<\/h4>\n\n<ul>\n<li>Plugin now follows WP coding standard<\/li>\n<li>Fixed a small bug where DFI overrides attachments featured images. mp3 has a music note by default, DFI should not override that.<\/li>\n<\/ul>\n\n<h4>1.6.1<\/h4>\n\n<ul>\n<li>Small readme.txt update.<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<ul>\n<li>On of the last fixes didn't account for all situations.<\/li>\n<\/ul>\n\n<h4>1.5<\/h4>\n\n<ul>\n<li>Fixed two small (and rare) warnings<\/li>\n<li>Added translation domain<\/li>\n<\/ul>\n\n<h4>1.4<\/h4>\n\n<ul>\n<li>Added plugin images both the plugin header as the thumbnail. Based on the boat WP.org uses in it's theme previews<\/li>\n<li>Fixed a bug where the ajax calls didn't return the DFI <a href=\"https:\/\/wordpress.org\/support\/topic\/dfi-woocommerce-facetwp?replies=10\">forum thread<\/a><\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>Filter <code>dfi_thumbnail_id<\/code> now also returns the post ID of the post (or any postype) that is being called. See the FAQ for new examples<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>Filter <code>dfi_thumbnail_id<\/code> is now called in an earlier stage.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Fixed inheriting classes of the image<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Plugin will now remove it's setting on plugin removal<\/li>\n<li>added a default class to the <code>&lt;img&gt;<\/code> tag, if it shows a default featured image<\/li>\n<li>The default featured image will now also return with <code>get_post_thumbnail_id<\/code>, making the chance that it fail far far smaller.<\/li>\n<li>The image given in the media page is now validated<\/li>\n<\/ul>\n\n<h4>0.9<\/h4>\n\n<ul>\n<li>Launch<\/li>\n<\/ul>","raw_excerpt":"Add a Default Featured Image for all posts &amp; pages.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/21354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=21354"}],"author":[{"embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/janwoostendorp"}],"wp:attachment":[{"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=21354"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=21354"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=21354"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=21354"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=21354"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/ur.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=21354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}