Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9938b87

Browse files
committedDec 9, 2024·
fix: remove srcset and sizes image attributes from image tags"
1 parent 86d379a commit 9938b87

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed
 

‎functions.php

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -416,21 +416,21 @@ function utopia_is_current_url( string $test_url, $include_params = false ) {
416416
add_filter( 'post_thumbnail_html', 'utopia_remove_dimension_image_attributes', 10 );
417417
add_filter( 'image_send_to_editor', 'utopia_remove_dimension_image_attributes', 10 );
418418
/**
419-
* Removes width and height attributes from images.
419+
* Removes width, height, srcset, and sizes attributes from images.
420420
*
421-
* These attributes are added by WordPress and are not necessary for the
421+
* These attributes are added by WordPress and may not be necessary for the
422422
* responsive images generated by the theme. By removing them, we prevent
423423
* unnecessary requests for image dimensions and potentially reduce page
424424
* load times.
425425
*
426426
* @param string $image The image HTML markup.
427427
*
428-
* @return string The filtered image HTML markup without width and height
429-
* attributes.
428+
* @return string The filtered image HTML markup without width, height, srcset,
429+
* and sizes attributes.
430430
*/
431431
function utopia_remove_dimension_image_attributes( string $image ): string {
432432
$image = preg_replace(
433-
'/(width|height)="\d*"\s/',
433+
'/(width|height|srcset|sizes)="[^"]*"\s*/',
434434
'',
435435
$image
436436
);
@@ -767,13 +767,13 @@ function utopia_format_email_link( string $email, string $subject = '' ): string
767767
}
768768

769769
// function cf_search_join( $join ) {
770-
// global $wpdb;
770+
// global $wpdb;
771771

772-
// if ( is_search() ) {
773-
// $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
774-
// }
772+
// if ( is_search() ) {
773+
// $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
774+
// }
775775

776-
// return $join;
776+
// return $join;
777777
// }
778778
// add_filter('posts_join', 'cf_search_join' );
779779

@@ -783,15 +783,15 @@ function utopia_format_email_link( string $email, string $subject = '' ): string
783783
// * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
784784
// */
785785
// function cf_search_where( $where ) {
786-
// global $pagenow, $wpdb;
786+
// global $pagenow, $wpdb;
787787

788-
// if ( is_search() ) {
789-
// $where = preg_replace(
790-
// "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
791-
// "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
792-
// }
788+
// if ( is_search() ) {
789+
// $where = preg_replace(
790+
// "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
791+
// "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
792+
// }
793793

794-
// return $where;
794+
// return $where;
795795
// }
796796
// add_filter( 'posts_where', 'cf_search_where' );
797797

@@ -801,13 +801,13 @@ function utopia_format_email_link( string $email, string $subject = '' ): string
801801
// * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
802802
// */
803803
// function cf_search_distinct( $where ) {
804-
// global $wpdb;
804+
// global $wpdb;
805805

806-
// if ( is_search() ) {
807-
// return "DISTINCT";
808-
// }
806+
// if ( is_search() ) {
807+
// return "DISTINCT";
808+
// }
809809

810-
// return $where;
810+
// return $where;
811811
// }
812812
// add_filter( 'posts_distinct', 'cf_search_distinct' );
813813

@@ -819,20 +819,20 @@ function utopia_search_site_content_via_ajax() {
819819
}
820820

821821
$query_args = array(
822-
'post_type' => array( 'post', 'utopian', 'concert' ),
823-
's' => sanitize_text_field( wp_unslash( $_POST['s'] ) ),
822+
'post_type' => array( 'post', 'utopian', 'concert' ),
823+
's' => sanitize_text_field( wp_unslash( $_POST['s'] ) ),
824824
// 'meta_query' => array(
825-
// 'relation' => 'OR',
826-
// array(
827-
// 'key' => 'start_date',
828-
// 'compare' => 'NOT EXISTS',
829-
// ),
830-
// array(
831-
// 'key' => 'start_date',
832-
// 'value' => gmdate( 'Y-m-d H:i:s' ),
833-
// 'type' => 'DATETIME',
834-
// 'compare' => '>=',
835-
// ),
825+
// 'relation' => 'OR',
826+
// array(
827+
// 'key' => 'start_date',
828+
// 'compare' => 'NOT EXISTS',
829+
// ),
830+
// array(
831+
// 'key' => 'start_date',
832+
// 'value' => gmdate( 'Y-m-d H:i:s' ),
833+
// 'type' => 'DATETIME',
834+
// 'compare' => '>=',
835+
// ),
836836
// ),
837837
);
838838

@@ -1098,13 +1098,13 @@ function utopia_acf_validate_lead( $valid, $value, $field ) {
10981098

10991099
// add_filter( 'acf/validate_value/key=field_66365be62f501', 'utopia_acf_validate_concert_content_field', 10, 3 );
11001100
// function utopia_acf_validate_concert_content_field( $valid, $value, $field ) {
1101-
// $value = preg_replace( '/\s+/', '', $value );
1101+
// $value = preg_replace( '/\s+/', '', $value );
11021102

1103-
// if ( strlen( $value ) < 3 ) {
1104-
// return 'The concert field should be up to 3 characters without spaces.';
1105-
// }
1103+
// if ( strlen( $value ) < 3 ) {
1104+
// return 'The concert field should be up to 3 characters without spaces.';
1105+
// }
11061106

1107-
// return true;
1107+
// return true;
11081108
// }
11091109

11101110
add_filter( 'acf/validate_value/key=field_6636398d8dd00', 'utopia_acf_validate_role', 10, 3 );

0 commit comments

Comments
 (0)
Please sign in to comment.