get_block_core_post_featured_image_overlay_element_markup( array $attributes ): string
- Since
- 6.1.0
- Source
wp-includes/blocks/post-featured-image.php:149
Compatibility
- WordPress
- since 6.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$attributesarray- Block attributes.
Return value
string- HTML markup in string format.
Performance profile
How much work a call to get_block_core_post_featured_image_overlay_element_markup() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 20–96
- Plugin surface
- None
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 99.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()one call below get_block_core_post_featured_image_overlay_element_markup()
Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_block_core_post_featured_image_overlay_element_markup() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($attributes) | 20–28 | none |
!isset($attributes) | 56–96 | get_block_core_post_featured_image_border_attributes(), esc_attr(), safecss_filter_attr(), esc_attr() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 99 | 20–96 | 14 | |
| 8.5 | 99 | 20–96 | 14 | |
| 8.4 | 99 | 20–96 | 14 | 8 fewer instructions than PHP 8.3 |
| 8.3 | 107 | 20–104 | 14 | |
| 8.2 | 107 | 20–104 | 14 | |
| 8.1 | 107 | 20–104 | 14 | |
| 7.4 | 107 | 20–104 | 14 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 3
- get_block_core_post_featured_image_border_attributes()Generates class names and styles to apply the border support styles for the Post Featured Image block.
- esc_attr()Escaping for HTML attributes.
- safecss_filter_attr()Filters an inline style attribute and removes disallowed rules.
Used by · 1
- render_block_core_post_featured_image()Renders the `core/post-featured-image` block on the server.
Source code
function get_block_core_post_featured_image_overlay_element_markup( $attributes ) { $has_dim_background = isset( $attributes['dimRatio'] ) && $attributes['dimRatio']; $has_gradient = isset( $attributes['gradient'] ) && $attributes['gradient']; $has_custom_gradient = isset( $attributes['customGradient'] ) && $attributes['customGradient']; $has_solid_overlay = isset( $attributes['overlayColor'] ) && $attributes['overlayColor']; $has_custom_overlay = isset( $attributes['customOverlayColor'] ) && $attributes['customOverlayColor']; $class_names = array( 'wp-block-post-featured-image__overlay' ); $styles = array(); if ( ! $has_dim_background ) { return ''; } // Apply border classes and styles. $border_attributes = get_block_core_post_featured_image_border_attributes( $attributes ); if ( ! empty( $border_attributes['class'] ) ) { $class_names[] = $border_attributes['class']; } if ( ! empty( $border_attributes['style'] ) ) { $styles[] = $border_attributes['style']; } // Apply overlay and gradient classes. $class_names[] = 'has-background-dim'; $class_names[] = "has-background-dim-{$attributes['dimRatio']}"; if ( $has_solid_overlay ) { $class_names[] = "has-{$attributes['overlayColor']}-background-color"; } if ( $has_gradient || $has_custom_gradient ) { $class_names[] = 'has-background-gradient'; } if ( $has_gradient ) { $class_names[] = "has-{$attributes['gradient']}-gradient-background"; } // Apply background styles. if ( $has_custom_gradient ) { $styles[] = sprintf( 'background-image: %s;', $attributes['customGradient'] ); } if ( $has_custom_overlay ) { $styles[] = sprintf( 'background-color: %s;', $attributes['customOverlayColor'] ); } return sprintf( '<span class="%s" style="%s" aria-hidden="true"></span>', esc_attr( implode( ' ', $class_names ) ), esc_attr( safecss_filter_attr( implode( ' ', $styles ) ) ) );}Changelog
Introduced in 6.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/post-featured-image.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.