Hook: post.default_image
Last updated on May 21, 2026 05:07
Overview
Type: Filter
Location: app/helpers.php - get_default_post_image()
Allows themes and modules to override the fallback image displayed when a post has no featured image. The administrator sets a global default via Settings > Reading > Default Post Image. This filter runs after that value is retrieved, giving developers a chance to return a different URL based on context.
Parameters
| Param | Type | Description |
|---|---|---|
$imageUrl |
string or null | Current default image URL from settings |
$context |
mixed | Post model instance (or null) |
Return
Must return string|null - the image URL to use, or null to fall back to the SVG placeholder.
Usage Example
Set a different default image per post category:
use App\Facades\Hook;
Hook::addFilter('post.default_image', function (?string $url, $post) {
if ($post?->categories->contains('slug', 'technology')) {
return '/images/defaults/tech-cover.jpg';
}
return $url;
});
Related Hooks
- post.frontend_url - Customize post public URL
- post.content.render - Filter post HTML before API response