is_right_sidebar_active() ) { $sizes = '(min-width: 960px) 75vw, 100vw'; } return $sizes; } /** * Filters the `sizes` value in the header image markup. * * @param string $html The HTML image tag markup being filtered. * @param object $header The custom header object returned by 'get_custom_header()'. * @param array $attr Array of the attributes for the image tag. * @return string The filtered header image HTML. */ public function filter_header_image_tag( string $html, $header, array $attr ): string { if ( isset( $attr['sizes'] ) ) { $html = str_replace( $attr['sizes'], '100vw', $html ); } return $html; } /** * Adds custom image sizes attribute to enhance responsive image functionality for post thumbnails. * * @param array $attr Attributes for the image markup. * @param mixed $attachment Attachment post object or other types. * @param string|array $size Registered image size or flat array of height and width dimensions. * @return array The filtered attributes for the image markup. */ public function filter_post_thumbnail_sizes_attr( array $attr, $attachment, $size ): array { // Ensure $attachment is an instance of WP_Post. if ( ! $attachment instanceof WP_Post ) { return $attr; // Return the original attributes if $attachment is not a WP_Post instance. } $attr['sizes'] = '100vw'; if ( buddyx()->is_right_sidebar_active() ) { $attr['sizes'] = '(min-width: 960px) 75vw, 100vw'; } return $attr; } }