Changeset 14016 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php
- Timestamp:
- 09/03/2024 04:51:13 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2024/functions.php
r14005 r14016 55 55 add_filter( 'single_template_hierarchy', __NAMESPACE__ . '\modify_single_template' ); 56 56 add_filter( 'taxonomy_template_hierarchy', __NAMESPACE__ . '\modify_taxonomy_template_hierarchy' ); 57 add_filter( 'wp_calculate_image_sizes', __NAMESPACE__ . '\modify_grid_image_sizes', 10, 5 ); 57 58 add_filter( 'wp_get_attachment_image_attributes', __NAMESPACE__ . '\eager_load_first_card_rows_images', 10, 3 ); 58 59 add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' ); … … 167 168 168 169 return $attr; 170 } 171 172 /** 173 * Modify the image sizes attribute to improve performance by loading the size that is closest to the grid column width. 174 */ 175 function modify_grid_image_sizes( $sizes, $size, $image_src, $image_meta, $attachment_id ) { 176 if ( is_front_page() || is_archive() || is_search() || is_page( 'my-courses' ) ) { 177 return '(max-width: 768px) 100vw, (max-width: 1270px) 50vw, 33vw'; 178 } 179 180 return $sizes; 169 181 } 170 182
Note: See TracChangeset
for help on using the changeset viewer.