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 dimensions of logo

You can use getimagesize() for this purpose:

list($width, $height) = getimagesize(esc_url( get_theme_mod( 'mitch_logo' ) ));

echo ".logo {
    width:{$width}px;
    height:{$height}px;
    background: ...;
}";

If that adds a little milliseconds to your page load time, I can edit this to provide a JavaScript version of the answer 🙂

Hope that helps.

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. Theme Options Page – User Updates Logo
  4. Enable custom logo upload if logo is not in header
  5. Three Questions with Twenty Eleven theme
  6. How to set the WordPress logo programmatically with PHP
  7. How to change logo by category
  8. get_header_image() causes “Prioritize visible content” issue in Page Speed Insights
  9. Logo custom width not implementing
  10. Convert hex color to RGB values in PHP
  11. Calculate business days
  12. How do I make a redirect in PHP?
  13. How to add elements to an empty array in PHP?
  14. What do ++ and *+ mean?
  15. What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
  16. Undefined function mysql_connect()
  17. MySQL column count doesn’t match value count at row 1 [closed]
  18. Matching a space in regex
  19. Undefined function mysql_connect()
  20. How can I send an email using PHP?
  21. Fatal error: Call to undefined function mysql_connect()
  22. count() parameter must be an array or an object that implements countable in laravel
  23. Go Back to Previous Page
  24. How do I check if a string contains a specific word?
  25. How do I replace part of a string in PHP? [duplicate]
  26. How to declare a global variable in php?
  27. How to fix “Headers already sent” error in PHP
  28. Fatal error: Call to undefined function mysql_connect()
  29. How to fix ‘Notice: Undefined index:’ in PHP form action
  30. Loop through an array php
  31. Deprecated: mysql_connect()
  32. Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)
  33. Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error
  34. Illegal string offset Warning PHP
  35. What is PHPSESSID?
  36. MySQL “Or” Condition
  37. What is the significance of the number, 32767?
  38. PHP – how to create a newline character?
  39. How to add a line break within echo in PHP?
  40. How to read a large file line by line?
  41. Best way to do multiple constructors in PHP
  42. How to get URL of current page displayed?
  43. Undefined variable in functions.php file [closed]
  44. What are PHP extensions and libraries WP needs and/or uses?
  45. What is the correct way to use WordPress functions outside WordPress files?
  46. Allow HTML in excerpt
  47. How to get WordPress Time Zone setting?
  48. how to get page id of a page using page slug
  49. Check if current page is the Blog Page
  50. How to set and use global variables? Or why not to use them at all
  51. Sending the reset password link programatically
  52. How to add product in woocommerce with php code [closed]
  53. Show all terms of a custom taxonomy?
  54. How exactly do automatic updates work?
  55. what is correct way to hook when update post
  56. How to update custom fields using the wp_insert_post() function?
  57. How to create custom 401, 403 and 500 error pages?
  58. Why have on every line
  59. Most efficient way to add javascript file to specific post and/or pages?
  60. Running WP Cron on multisite the right way
  61. Getting only direct child pages in WordPress with get_pages
  62. the_date() not working
  63. How do I use WP_query with multiple post IDs?
  64. How to return number of found rows from SELECT query
  65. Query multiple custom post types in single loop
  66. How to include checkbox in widget backend form?
  67. Setting $_SERVER[‘HTTPS’]=’on’ prevents access to wp-admin
  68. How to deprecate a function used in a plugin?
  69. get current category ID php
  70. Converting timestamps to local time with date_l18n()
  71. To close or not to close php
  72. How to manually fix the WordPress gallery code using PHP in functions.php?
  73. What is the meaning of %s, %1$s etc.? [closed]
  74. Contact form redirecting to page not found on send
  75. User registration followed by automatic login
  76. Setting custom cookies in WordPress
  77. Adding first / last CSS classes to menus
  78. Remove update nags for non-admins [duplicate]
  79. Are WordPress Heartbeat API ‘beats’ staggered or do they occur simultaneously for all users?
  80. How to correctly add Javascript in functions.php
  81. Display current category title on category page
  82. Can I use the same nonce for multiple requests on the same page?
  83. Why isn’t WordPress part of Framework Interop Group?
  84. WordPress and magic quotes
  85. How to check if a plugin (WooCommerce) is active?
  86. How to check if a string is a valid URL
  87. Best Practice for PHP
  88. Is there a way to use the WordPress users but without loading the entire WordPress core?
  89. WordPress refuses to send mail, “…your host may have disabled the mail() function”
  90. How does printf( __( ) ); work?
  91. How to fix the admin menu margin-top bug in WordPress 5.5?
  92. How to make a image-size selected by default in Media upload – WP v3.5
  93. Override get_template_directory() in child theme?
  94. Return HTML Template Page with PHP Function
  95. Only get_posts of certain post formats
  96. How to trigger WooCommerce order complete email?
  97. What is This esc_html_e() i wordpress php?
  98. Should I use spl_autoload_register() in my plugin?
  99. How to check if woocommerce is activated in theme
  100. Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
Categories PHP Tags logo, php
Newest comments first not working
Hook for plugin to show content for certain urls

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