On this page
get_site_icon_url( int $size = 512, string $url = '', int $blog_id ): string
Returns the Site Icon URL.
Parameters
$sizeint Optional-
Size of the site icon. Default 512 (pixels).
Default:
512 $urlstring Optional-
Fallback url if no site icon is found.
Default:
'' $blog_idint Optional-
ID of the blog to get the site icon for. Default current blog.
Return
string Site Icon URL.
Source
File: wp-includes/general-template.php. View all references
function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
switch_to_blog( $blog_id );
$switched_blog = true;
}
$site_icon_id = get_option( 'site_icon' );
if ( $site_icon_id ) {
if ( $size >= 512 ) {
$size_data = 'full';
} else {
$size_data = array( $size, $size );
}
$url = wp_get_attachment_image_url( $site_icon_id, $size_data );
}
if ( $switched_blog ) {
restore_current_blog();
}
/**
* Filters the site icon URL.
*
* @since 4.4.0
*
* @param string $url Site icon URL.
* @param int $size Size of the site icon.
* @param int $blog_id ID of the blog to get the site icon for.
*/
return apply_filters( 'get_site_icon_url', $url, $size, $blog_id );
}
Hooks
- apply_filters( 'get_site_icon_url',
string $url ,int $size ,int $blog_id ) -
Filters the site icon URL.
Related
Uses
| Uses | Description |
|---|---|
| wp_get_attachment_image_url() wp-includes/media.php | Gets the URL of an image attachment. |
| switch_to_blog() wp-includes/ms-blogs.php | Switch the current blog. |
| restore_current_blog() wp-includes/ms-blogs.php | Restore the current blog, after calling switch_to_blog() . |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| get_current_blog_id() wp-includes/load.php | Retrieve the current site ID. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Server::add_site_icon_to_index() wp-includes/rest-api/class-wp-rest-server.php | Exposes the site icon through the WordPress REST API. |
| do_favicon() wp-includes/functions.php | Displays the favicon.ico file content. |
| the_embed_site_title() wp-includes/embed.php | Prints the necessary markup for the site title in an embed template. |
| wp_site_icon() wp-includes/general-template.php | Displays site icon meta tags. |
| site_icon_url() wp-includes/general-template.php | Displays the Site Icon URL. |
| has_site_icon() wp-includes/general-template.php | Determines whether the site has a Site Icon. |
| atom_site_icon() wp-includes/feed.php | Displays Site Icon in atom feeds. |
| rss2_site_icon() wp-includes/feed.php | Displays Site Icon in RSS2. |
| wp_admin_bar_my_sites_menu() wp-includes/admin-bar.php | Adds the “My Sites/[Site Name]” menu and all submenus. |
Changelog
| Version | Description |
|---|---|
| 4.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_site_icon_url