PHPackages                             bmd/featured-image-block-fallback - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. bmd/featured-image-block-fallback

ActiveLibrary[Image &amp; Media](/categories/media)

bmd/featured-image-block-fallback
=================================

Provide a fallback image for the featured image block

v0.3.4(1mo ago)069GPL-2.0-or-laterPHPCI passing

Since Mar 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/bob-moore/Featured-Image-Block-Fallback)[ Packagist](https://packagist.org/packages/bmd/featured-image-block-fallback)[ Docs](https://github.com/bob-moore/Featured-Image-Block-Fallback)[ RSS](/packages/bmd-featured-image-block-fallback/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (11)Versions (15)Used By (0)

[![Featured Image Block Fallback](assets/banner-1544x500.jpg)](assets/banner-1544x500.jpg)

Featured Image Block Fallback
=============================

[](#featured-image-block-fallback)

[![WordPress](https://camo.githubusercontent.com/9019993b03d9eacdbbcaa62a8afa65eea7718177d5d0a91a692a4281aff395ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576f726450726573732d362e352532422d3338353865393f6c6f676f3d776f72647072657373266c6f676f436f6c6f723d666666)](https://wordpress.org/)[![PHP](https://camo.githubusercontent.com/8da406bc1dd3dcb38541095055eef712a822936eee12a6c185a71f6e678091b2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737376262343f6c6f676f3d706870266c6f676f436f6c6f723d666666)](https://www.php.net/)[![Latest Release](https://camo.githubusercontent.com/7191508d5cd7b46b6f0bea89028901febf6d81c38d3f38e19e20c558e8b4e684/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f626f622d6d6f6f72652f46656174757265642d496d6167652d426c6f636b2d46616c6c6261636b3f6c6162656c3d72656c65617365)](https://github.com/bob-moore/Featured-Image-Block-Fallback/releases/latest)[![License](https://camo.githubusercontent.com/cd781d0568c328bdea35f284d33e2b1e96675ef60910926c1dd75d5a4d46de66/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c2d2d322e302d2d6f722d2d6c617465722d626c7565)](https://www.gnu.org/licenses/gpl-2.0.html)

[![Lint CSS](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-css.yml/badge.svg)](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-css.yml)[![Lint JS](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-js.yml/badge.svg)](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-js.yml)[![Lint PHP](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-php.yml/badge.svg)](https://github.com/bob-moore/Featured-Image-Block-Fallback/actions/workflows/lint-php.yml)

Add a fallback image to the `core/post-featured-image` block for posts that have no featured image set.

What this does
--------------

[](#what-this-does)

The WordPress `core/post-featured-image` block is great—until a post doesn't have a featured image. By default, it simply renders nothing, leaving an awkward gap in your design.

Featured Image Block Fallback solves this by allowing you to specify a fallback image directly on the block. It displays whenever a post lacks a featured image—no global settings, no unnecessary bloat.

Whether you're building custom templates, using query loops, or designing unique layouts, this plugin ensures your site looks polished even when a featured image is missing.

Features
--------

[](#features)

- Adds a fallback image control to the `core/post-featured-image` block in the editor
- Optionally skips the fallback when the post already contains an inline image
- Filterable fallback ID (`featured_image_block_fallback_id`) for per-post-type customization
- Works as a standalone plugin or reusable Composer dependency

Requirements
------------

[](#requirements)

- WordPress 6.5+
- PHP 8.2+

Installation
------------

[](#installation)

### Install as a plugin

[](#install-as-a-plugin)

1. Download the latest release zip from the [GitHub Releases page](https://github.com/bob-moore/Featured-Image-Block-Fallback/releases).
2. In WordPress admin, go to **Plugins &gt; Add New Plugin &gt; Upload Plugin**.
3. Upload the zip and activate **Featured Image Block Fallback**.

### Install via Composer

[](#install-via-composer)

If you are embedding this into your own project:

```
composer require bmd/featured-image-block-fallback
```

If your parent plugin already uses PHP-DI, you can load this package's definitions into the parent container and override only the install-specific path and URL values:

```
use Bmd\FeaturedImageBlockFallback\Controller;
use Bmd\FeaturedImageBlockFallback\Services\FilePathResolver;
use Bmd\FeaturedImageBlockFallback\Services\UrlResolver;
use function DI\autowire;
use function DI\string;

$definitions = require __DIR__ . '/vendor/bmd/featured-image-block-fallback/inc/definitions.php';

return array_merge(
    $definitions,
    [
        FilePathResolver::class => autowire()
            ->constructorParameter(
                'path',
                string( '{path}vendor/bmd/featured-image-block-fallback/' )
            ),

        UrlResolver::class => autowire()
            ->constructorParameter(
                'url',
                string( '{url}vendor/bmd/featured-image-block-fallback/' )
            ),
    ]
);
```

Then ask your parent container for `Controller::class` and call `register()` during your plugin bootstrap.

If your parent plugin does not use PHP-DI, load the dependency through its `Main` class so the package can build its own container:

```
use Bmd\FeaturedImageBlockFallback\Main;

$featured_image_fallback = new Main(
    [
        'package' => 'featured_image_block_fallback',
        'path'    => plugin_dir_path( __FILE__ ) . 'vendor/bmd/featured-image-block-fallback/',
        'url'     => plugin_dir_url( __FILE__ ) . 'vendor/bmd/featured-image-block-fallback/',
    ]
);

$featured_image_fallback->register();
```

Both examples should point `path` and `url` at the Featured Image Block Fallback dependency root, not the parent plugin root.

Usage
-----

[](#usage)

1. Add a **Post Featured Image** block to a template or query loop.
2. Open the block sidebar and expand the **Fallback Image** panel.
3. Select a fallback image using the media picker.
4. Optionally enable **Use First Image from Post** to skip the fallback when the post already has an inline image.
5. Save the template.

Updates
-------

[](#updates)

This plugin is distributed through GitHub releases (not WordPress.org). The plugin includes a scoped GitHub updater so WordPress can detect and apply new versions from this repository.

Frequently Asked Questions
--------------------------

[](#frequently-asked-questions)

### Can I set a different fallback image for different post types?

[](#can-i-set-a-different-fallback-image-for-different-post-types)

Yes. Since the fallback image is set directly on the block, you can assign different fallback images to each query loop or post template that uses `core/post-featured-image`.

Developers can also customize the fallback dynamically using the `featured_image_block_fallback_id` filter:

```
add_filter( 'featured_image_block_fallback_id', function( int $fallback_id, array $block ): int {
    if ( get_post_type( get_the_ID() ) === 'my-custom-post-type' ) {
        return 123; // Replace with your fallback image ID.
    }
    return $fallback_id;
}, 10, 2 );
```

### Can I override the asset path or URL?

[](#can-i-override-the-asset-path-or-url)

Yes. Filter `featured_image_block_fallback_plugin_path` or `featured_image_block_fallback_plugin_url` to redirect asset resolution.

### Is this plugin available on the official WordPress plugin repository?

[](#is-this-plugin-available-on-the-official-wordpress-plugin-repository)

No. It is distributed via GitHub only.

Changelog
---------

[](#changelog)

### 0.3.3

[](#033)

- Fixed package URL detection so plugin installs resolve from the root plugin file.
- Guarded theme-context detection against empty theme paths in non-WordPress test/bootstrap environments.

### 0.3.2

[](#032)

- Unified plugin architecture around `Main`, `Controller`, service providers, and PHP-DI definitions.
- Updated namespace from `Bmd\` to `Bmd\FeaturedImageBlockFallback\` for safer standalone and Composer usage.
- Added release packaging with scoped vendor dependencies, a compiled container, Docker build support, and wp-env defaults.
- Replaced `buildPath()`/`buildUrl()` helper methods with inline path construction.
- Simplified `getScriptAssets()` into `getAssetData( string $key )`.
- Replaced combined lint-build workflow with separate `lint-css`, `lint-js`, and `lint-php` workflows.
- Removed `FallbackPreview` editor component (stashed for future work).

### 0.3.1

[](#031)

- Added scoped `bmd/github-wp-updater` bootstrap so GitHub releases can be delivered through the WordPress update UI.
- Added `wpify/scoper` release packaging configuration and a dedicated scoped dependency manifest.
- Refreshed release packaging workflow and prepared production release artifacts for GitHub distribution.

### 0.3.0

[](#030)

- Added `BasicPlugin` interface; `FeaturedImageBlockFallback` now implements it.
- Constructor now accepts URL and path directly with sanitized defaults.
- Added `buildPath()` and `buildUrl()` with filterable asset resolution.
- Fixed plugin bootstrap to pass URL and path to the constructor instead of `mount()`.

### 0.1.8

[](#018)

- Updated typo in plugin metadata.
- Explicitly declared asset path for the updater in the main plugin file.

### 0.1.5

[](#015)

- Added external updater dependency.

### 0.1.4

[](#014)

- Finalized initial public stable release.

### 0.1.0 – 0.1.3

[](#010--013)

- Created GitHub updater integration.
- Version bumps for testing updater and releases.
- Initial upload.

License
-------

[](#license)

GPL-2.0-or-later. See [LICENSE](https://www.gnu.org/licenses/gpl-2.0.html).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance89

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~9 days

Total

13

Last Release

53d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/adf6af151397e0b108508ed9a8554fa09dc00f90864873446e76fa5b17463e23?d=identicon)[bobjutsu](/maintainers/bobjutsu)

---

Top Contributors

[![bob-moore](https://avatars.githubusercontent.com/u/1745619?v=4)](https://github.com/bob-moore "bob-moore (41 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bmd-featured-image-block-fallback/health.svg)

```
[![Health](https://phpackages.com/badges/bmd-featured-image-block-fallback/health.svg)](https://phpackages.com/packages/bmd-featured-image-block-fallback)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k85](/packages/elgg-elgg)[phlak/directory-lister

PHP directory lister

2.5k1.4k](/packages/phlak-directory-lister)[infinum/eightshift-libs

WordPress libs developed by Eightshift team to use in modern WordPress.

63125.5k3](/packages/infinum-eightshift-libs)[drupal-code-builder/drupal-code-builder

Code generator for Drupal

27253.3k1](/packages/drupal-code-builder-drupal-code-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
