Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

get_header_image() causes “Prioritize visible content” issue in Page Speed Insights

I came across this question while having a similar issue with a few of my sites and confirmed, as you did, that the logo above the fold was the issue in each case. I am not using get_header_image() but rather referencing a static image location so the issue isn’t specific to that. In fact, I even had a site with two images above the fold, only one of which actually triggered the warning.

Someone else had a related question, which I attempted to answer. I am not sure what the Stack Exchange rules/etiquette is for answering two similar questions. You can read my full reply at the other question. But, perhaps it is better/recommended that I repeat that answer here? If so, here goes:

I have read in a Google forum thread that if you simply specify the exact dimensions of your image you will pass the PVC test but I find that to be untrue. For me, that is necessary but the actual dimensions matter as well.

Unfortunately, after some experimentation, I cannot seem to find any consistent pattern or solution that sheds light on how Google decides what triggers a PVC warning, but the most interesting thing I noticed is that I didn’t actually have to change my image. I simply had to scale it down via the width and height declarations, which would indicate that file size is probably not the relevant factor.

Of course, the small sample size (3 of my sites) and the fact that all of my sites use the same theme means that I may be generalizing incorrectly. Still, it is worth experimenting with if you run into the same issue. For my testing, I created a function to generate the logo image code with width and height specifications that can be easily adjusted. Perhaps overkill, but I wrote the function to consider any of three possible global scaling variables, which I declare in my theme’s functions.php file:

  1. $GLOBALS['image_ratio']
  2. $GLOBALS['image_maxheight']
  3. $GLOBALS['image_maxwidth']

I then check if any of these is set and recalculate the width and height values appropriate based on the original image dimensions. Here is the final code:

if ( ! function_exists( 'se103976_scale_image' ) ) {
    function se103976_scale_image() {
        $image_alt = get_bloginfo( 'name' );
        $image_src = "https://wordpress.stackexchange.com/questions/265838/image.png";   // --- whatever image you want to use (with relevant path)
        list( $image_width, $image_height ) = getimagesize( $image_src );

        // --- Sometimes need to reduce image to pass Google PageSpeed Prioritize Visible Content warning 
        // --- So, can do by a ratio, by a max width or a max height, depending on global variable set in functions.php file 
        if ( $GLOBALS['image_ratio'] != false) { 
            $image_width = round($GLOBALS['image_ratio'] * $image_width);
            $image_height = round($GLOBALS['image_ratio'] * $image_height);
        }
        if ( $GLOBALS['image_maxheight'] != false) {
            if ($image_height > $GLOBALS['image_maxheight']) {
                $ratio = $GLOBALS['image_maxheight'] / $image_height;
                $image_height = $GLOBALS['image_maxheight'];
                $image_width = round($image_width * $ratio);
            }
        }
        if ( $GLOBALS['image_maxwidth'] != false) {
            if ($image_width > $GLOBALS['image_maxwidth']) {
                $ratio = $GLOBALS['image_maxwidth'] / $image_width;
                $image_width = $GLOBALS['image_maxwidth'];
                $image_height = round($image_height * $ratio);
            }
        }
?><img alt="<?php echo $image_alt; ?>" src="<?php echo $image_src; ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" /><?php
    }
}

Once I found the dimensions that would eliminate the PVC warning, I used an online image resizer to resize and replace my original image.

Related Posts:

  1. Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
  2. Changing custom logo link
  3. From where the header-text can be changed in WordPress custom header?
  4. Theme Options Page – User Updates Logo
  5. Enable custom logo upload if logo is not in header
  6. Three Questions with Twenty Eleven theme
  7. How to set the WordPress logo programmatically with PHP
  8. How to change logo by category
  9. Replace header with large image on home page only, using Genesis child theme
  10. Logo custom width not implementing
  11. Get dimensions of logo
  12. Adding else if conditional statement to purchased theme
  13. Create custom API endpoint to change custom header image
  14. Undefined offset: 3 in custom function
  15. List all blogs, but exclude the main site
  16. How to append to an array and return the results in a filter?
  17. How to specify the path for require_once in a child theme?
  18. Set site title & tagline with wp.config or function.php
  19. How can I add a new row in a separate database when someone registers via WordPress?
  20. Shortcode to embed Edit Account form not working
  21. Redirecting to a custom forgot password page
  22. How to pass a variable to get_template_part that’s updated every time the template part is called?
  23. Warning: printf(): Too few arguments in helpers.php file
  24. $_SESSION variable not saving on page refresh or new page
  25. Form search query – displaying ACF “Post Object” field as results
  26. Errors after upgrading PHP to 7.4 WordPress
  27. Design with Elementor and code the rest?
  28. Add additional functions file instead of functions.php
  29. How to make jquery count down timer function manually editable
  30. Issue with fetching mysql data and displaying results via shortcode in webpage
  31. wp_insert_post() with HTML tags using PHP
  32. How to rename woocommerce-billing-fields
  33. Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
  34. InnerBlocks with allowedBlocks not working with acf_register_block
  35. Can a plugin redirect product page based on IF condition?
  36. Cant register rest routs from class instance
  37. Hierarchical taxonomy list with modificated term links
  38. How can i change variable if condition is not met
  39. Shortcode not staying inside div tag
  40. if isset not working for undefined index, how to fix
  41. HTML showing after PHP code in tag
  42. What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
  43. Decoded malware code [closed]
  44. Double Curly Brackets in Php
  45. Line breaks inside shortcode variable
  46. How to return site_url() without https://
  47. WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin
  48. How set a custom URL for a new theme file in WP?
  49. PHP-warning in post-template.php and no loading content on pages
  50. How to unlink all posts from tracking same amount of views
  51. Connecting to another server database from the wordpress plugin
  52. Site Health says I’m running an older version of PHP even after I upgraded to 7.4.4
  53. Login redirect. Check user meta and redirect accordingly
  54. PHP Notice: Undefined offset: -1 – Navigation Previous/Next
  55. WordPress REST API register_rest_route give a 500 error
  56. How to use wordpress function wp_enqueue_script() in php?
  57. Where to insert redirect code based on http_referer?
  58. Add class to website based on post taxonomy
  59. Form Submission Not Working In Custom Theme
  60. Need php code’s output to display underneath a Divi Module
  61. Where is the PHP code generating an element?
  62. How do I check or test a WordPress Auto Year Change Script?
  63. Parse error: syntax error, unexpected ‘,’
  64. Prevent redirect to wp-login.php
  65. Extending WP_Customize_Media_Control to return filename
  66. Insert page content into another page with a changed variable
  67. Decimal values via get_option() with custom local (decimal point = comma)
  68. WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
  69. Noindex Posts From Certain Authors In WordPress
  70. In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
  71. Use get() method to grab all categories and output inside another method
  72. Seo Friendly Filter URLs
  73. Include only posts with meta key “add_in_rss” in RSS Feed
  74. Pass Variables or Variable Place-Holder from Editor to PHP
  75. Convert a string into a decimal number for use in query
  76. Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?
  77. Issue with custom loop in Archive page
  78. Use custom template on custom post type
  79. How to display SQL query that ran in WC_Order_Query?
  80. Site downloads files instead of loading them
  81. get_the_ID() doesnt work
  82. How to get specific attribute from DB
  83. Saving data from custom form in wordpress database
  84. PHP contact form not redirecting [closed]
  85. WooCommerce pages looks unstyled
  86. customize woocommerce templates and display store on home
  87. Add value to new attribute inside WordPress menu items
  88. Do I always need to call wp_get_current_user() before accessing $current_user?
  89. class ‘wphpc_PAnD’ not found
  90. Please show me how to use an if/else statement in combination with wp_enqueue
  91. How to make function appear in sentence?
  92. Accessing values from ACF sub field (flexible content area) in PHP
  93. Save html content of a widget textarea
  94. Creating an image from a custom field
  95. Widgets not showing on custom theme
  96. How to disable delivery on certain date at checkout page in WooCommerce?
  97. How to add no follow to specific links?
  98. Loop over Array and get the distinct ids
  99. WordPress transient not working with WP Engine
  100. How to define a variable already defined in a plugin function?
Categories PHP Tags header-image, logo, php
Index.php using 100% CPU [closed]
remove enclosure url from feed

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress