astra_replace_header_attr( array $attr, object $attachment, sting $size )
Replace header logo.
Description
Parameters
- $attr
-
(array) (Required) Image.
- $attachment
-
(object) (Required) Image obj.
- $size
-
(sting) (Required) Size name.
Return
(array) Image attr.
Source
File: inc/markup-extras.php
function astra_replace_header_attr( $attr, $attachment, $size ) { if ( ! isset( $attachment ) ) { return $attr; } $custom_logo_id = get_theme_mod( 'custom_logo' ); $is_logo_attachment = ( $custom_logo_id == $attachment->ID ) ? true : false; if ( apply_filters( 'astra_is_logo_attachment', $is_logo_attachment, $attachment ) ) { if ( ! is_customize_preview() ) { $attach_data = wp_get_attachment_image_src( $attachment->ID, 'ast-logo-size' ); if ( isset( $attach_data[0] ) ) { $attr['src'] = $attach_data[0]; } } $file_type = wp_check_filetype( $attr['src'] ); $file_extension = $file_type['ext']; if ( 'svg' == $file_extension ) { $existing_classes = isset( $attr['class'] ) ? $attr['class'] : ''; $attr['class'] = $existing_classes . ' astra-logo-svg'; } } if ( apply_filters( 'astra_is_retina_logo_attachment', $is_logo_attachment, $attachment ) ) { $diff_retina_logo = astra_get_option( 'different-retina-logo' ); if ( '1' == $diff_retina_logo ) { $retina_logo = astra_get_option( 'ast-header-retina-logo' ); $attr['srcset'] = ''; if ( apply_filters( 'astra_main_header_retina', true ) && '' !== $retina_logo ) { $cutom_logo = wp_get_attachment_image_src( $custom_logo_id, 'full' ); $cutom_logo_url = $cutom_logo[0]; if ( astra_check_is_ie() ) { // Replace header logo url to retina logo url. $attr['src'] = $retina_logo; } $attr['srcset'] = $cutom_logo_url . ' 1x, ' . $retina_logo . ' 2x'; } } } return apply_filters( 'astra_replace_header_attr', $attr ); }
Expand full source code Collapse full source code View on Trac