- This topic has 3 replies, 2 voices, and was last updated 1 year, 10 months ago by Tom.
-
AuthorPosts
-
November 21, 2022 at 5:59 pm #2426423Dan
Hi, I see a slow database query when I set a logo in the Mobile Header via the customiser –
customiser -> layout -> header -> mobile header -> logo
. The query is adding 0.5 of a second to each page load on average. The image it’s selecting is a well-optimised PNG, I’ve also tried a 1kb SVG with the same results.Screenshot of the query: https://capture.dropbox.com/L0q1onQHYAH5K30y
How can this query be better optimised?
November 22, 2022 at 8:13 pm #2428223TomLead DeveloperLead DeveloperHi there,
We’re aware of the
attachment_url_to_postid()
issues in WP, but it certainly shouldn’t be taking that long.We’re working on a solution so we can ditch that function completely in the next GPP.
For now, you can tell our function not to run and add your own.
You’ll just need to manually enter the image width/height.
add_action( 'after_setup_theme', function() { remove_action( 'generate_inside_mobile_header', 'generate_menu_plus_mobile_header_logo', 5 ); add_action( 'generate_inside_mobile_header', function() { $settings = wp_parse_args( get_option( 'generate_menu_plus_settings', array() ), generate_menu_plus_get_defaults() ); $image_width = '100'; // Your image width. $image_height = '100'; // Your image height. printf( '<div class="site-logo mobile-header-logo"> <a href="%1$s" title="%2$s" rel="home"> <img src="%3$s" alt="%4$s" class="is-logo-image" width="%5$s" height="%6$s" /> </a> </div>', esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), ! empty( $image_width ) ? absint( $image_width ) : '', ! empty( $image_height ) ? absint( $image_height ) : '' ); }, 5 ); } );
I’ve made sure to log this issue so it gets fixed in GPP 2.3.0.
Thanks!
November 23, 2022 at 12:15 pm #2429895DanThank you, Tom. Nice solution!
November 24, 2022 at 12:40 pm #2431793TomLead DeveloperLead DeveloperGlad I could help! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.