Make WordPress Core

Changeset 51978


Ignore:
Timestamp:
11/02/2021 05:20:35 PM (3 months ago)
Author:
johnjamesjacoby
Message:

Themes: Introduce get_header_image_tag_attributes hook.

This change adds a filter inside of the get_header_image_tag() function allowing developers to filter the attributes of the header image HTML tag before they are escaped, concatenated, and returned.

Before this change, it was not possible to externally and preemptively intercept this array of attributes. After this change, these attributes can now be easily filtered, matching it nicely to the wp_get_attachment_image_attributes hook.

Props audrasjb, chaion07, junaidbhura, sabernhardt.

Fixes #38942.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r51955 r51978  
    12341234        }
    12351235    }
     1236
     1237    /*
     1238     * Filters the list of header image attributes.
     1239     *
     1240     * @since 5.9.0
     1241     *
     1242     * @param array  $attr   Array of the attributes for the image tag.
     1243     * @param object $header The custom header object returned by 'get_custom_header()'.
     1244     */
     1245    $attr = apply_filters( 'get_header_image_tag_attributes', $attr, $header );
    12361246
    12371247    $attr = array_map( 'esc_attr', $attr );
Note: See TracChangeset for help on using the changeset viewer.