Changeset 13965 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php
- Timestamp:
- 08/13/2024 03:36:23 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php
r13944 r13965 28 28 */ 29 29 add_action( 'after_setup_theme', __NAMESPACE__ . '\setup' ); 30 add_filter( 'wp_get_attachment_image_attributes', __NAMESPACE__ . '\eager_load_first_card_row_images', 10, 3 ); 30 31 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' ); 31 32 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\maybe_enqueue_sensei_assets', 100 ); … … 139 140 140 141 /** 142 * Eagerly load the images for the first row of cards, for performance (LCP metric). 143 * 144 * @param array $attr The image attributes. 145 * @param WP_Post $attachment The attachment post object. 146 * @param string $size The image size. 147 * @return array The modified image attributes. 148 */ 149 function eager_load_first_card_row_images( $attr, $attachment, $size ) { 150 static $image_count = 0; 151 152 if ( is_front_page() || is_archive() || is_search() || is_page( 'my-courses' ) ) { 153 $image_count++; 154 155 if ( $image_count <= 3 ) { 156 $attr['loading'] = 'eager'; 157 $attr['fetchpriority'] = 'high'; 158 } 159 } 160 161 return $attr; 162 } 163 164 /** 141 165 * Sensei doesn't enqueue learning mode styles for Lessons which are not part of a course. 142 166 * Enqueue the styles and add the required body class if needed. … … 365 389 function set_default_featured_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) { 366 390 if ( ! $html ) { 367 return '<img src="https://s.w.org/images/learn-thumbnail-fallback.jpg?v= 4" alt="' . esc_attr( get_the_title( $post_id ) ) . '" />';391 return '<img src="https://s.w.org/images/learn-thumbnail-fallback.jpg?v=5" alt="' . esc_attr( get_the_title( $post_id ) ) . '" />'; 368 392 } 369 393
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)