Repository navigation
Default avatar snippets
Deutsch · Local avatars and administration conveniences · Home
The site_essentials_local_avatar_default_id filter lets you set a local default image centrally in code. It appears for users without a personal profile image. Local avatars must be enabled in Site Essentials and provided by Site Essentials. The filter does not enable the module itself.
No code is needed for ordinary image selection: under Site Essentials → Local avatars, upload a default image or choose one from the Media Library.
- Upload a local JPEG, PNG, GIF, WebP, or AVIF image to the relevant website’s Media Library.
- Find its image ID: open the image for editing from the media list view. In an address such as
post.php?post=123&action=edit,123is the ID. Alternatively, use Site Essentials’ optional ID column. - Add and activate one of the following examples in your site functionality plugin or a PHP snippet plugin. Snippet plugins usually expect PHP without the opening
<?php; in your own plugin, place it below the existing PHP opening tag.
No wp-config.php entry is needed. Do not edit Site Essentials itself: an update would overwrite that change.
Replace 123 with the desired image ID:
add_filter( 'site_essentials_local_avatar_default_id', function ( int $attachment_id ): int {
return 123;
} );Check the preview under Local avatars → Default image. A valid code override pauses image selection in the interface; the saved selection is retained.
The snippet must load on the intended website, for example through a network-activated site functionality plugin. Replace 2 with its site ID and 123 with an image ID from that website’s own Media Library:
add_filter( 'site_essentials_local_avatar_default_id', function ( int $attachment_id ): int {
if ( get_current_blog_id() !== 2 ) {
return $attachment_id;
}
return 123;
} );Find the site ID under Network Admin → Sites, for example in the editing address site-info.php?id=2. Other websites keep their existing selection.
A network-loaded snippet can supply a different local image ID for each website:
add_filter( 'site_essentials_local_avatar_default_id', function ( int $attachment_id ): int {
$images_by_site = array(
2 => 123,
5 => 456,
);
return $images_by_site[ get_current_blog_id() ] ?? $attachment_id;
} );Site IDs are on the left; image IDs from each site’s own Media Library are on the right. Replace the example values. Unlisted sites keep their existing selection. An image ID is not automatically valid on other sites; this does not access the main site’s Media Library.
- Personal profile images continue to take priority over the default image.
- The default image follows this order: valid filter override → saved local selection → shipped SE image.
- Only a positive integer ID for an available, public, locally served raster image is accepted. An invalid, deleted, or externally served image is not used as an override; the next available choice is used instead.
- The filter does not protect the media file from deletion or create another copy.
- Disable the snippet or return
0to remove its override. The saved image can then be changed in the interface again, provided no other valid filter override exists. - IDs belong to each website and are not portable between installations. Snippets are managed separately and are not included in SE preset exports.
Check the avatar display for a user without a personal image. Then confirm that another user’s personal image still takes priority. In multisite, also check an unlisted website. WordPress calls that explicitly request the default image use the effective default even when a personal image exists.
The filter is available since Site Essentials 1.1.0 and expects an integer attachment ID, not an image URL.
Site Essentials · Documentation / Dokumentation
Website EN · Website DE · Wiki home / Wiki-Startseite · Repository · Downloads & Releases
Help & bugs / Hilfe & Fehler · Discussions / Austausch · Security / Sicherheit
© 2026 David Decker – DECKERWEB.
Plugin: GPL v2 or later / GPL v2 oder höher.
- Home
- Getting started
- User guide
- All features at a glance
- Administration conveniences
- Default avatar snippets
- Dashboard information
- General settings explained
- Diagnostics and shortcuts
- Maintenance mode
- Website checks
- Replace Falcon and Unbloater
- FAQ by topic
- Changelog
- Help and security
- Startseite
- Erste Schritte
- Anleitung
- Alle Funktionen im Überblick
- Verwaltungshilfen
- Standard-Avatar per Code
- Dashboard-Informationen
- Allgemeine Einstellungen erklärt
- Diagnose und Einstiege
- Wartungsmodus
- Website-Prüfungen
- Falcon und Unbloater ersetzen
- Fragen nach Themen
- Änderungsverlauf
- Hilfe und Sicherheit