Astra_Ext_Sticky_Header_Markup::sticky_replace_header_logo_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: addons/sticky-header/classes/class-astra-ext-sticky-header-markup.php

		public function sticky_replace_header_logo_attr( $attr, $attachment, $size ) {

			$custom_logo    = astra_get_option( 'sticky-header-logo' );
			$custom_logo_id = attachment_url_to_postid( $custom_logo );

			if ( $custom_logo_id == $attachment->ID ) {

				$attach_data = array();
				if ( ! is_customize_preview() ) {
					$attach_data = wp_get_attachment_image_src( $attachment->ID, 'ast-sticky-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 ) {
					$attr['width']  = '100%';
					$attr['height'] = '100%';
					$attr['class']  = 'astra-logo-svg';
				}

				$diff_retina_logo = astra_get_option( 'different-sticky-retina-logo' );

				if ( '1' == $diff_retina_logo ) {

					$retina_logo    = astra_get_option( 'sticky-header-retina-logo' );
					$custom_logo    = $attr['src'];
					$attr['srcset'] = '';

					if ( '' !== $retina_logo ) {

						if ( astra_check_is_ie() ) {
							// Replace header logo url to retina logo url.
							$attr['src'] = $retina_logo;
						}

						$attr['srcset'] = $custom_logo . ' 1x, ' . $retina_logo . ' 2x';
					}
				}
			}

			return $attr;
		}


User Contributed Notes

You must log in before being able to contribute a note or feedback.