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:
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- Changing custom logo link
- Theme Options Page – User Updates Logo
- Enable custom logo upload if logo is not in header
- Three Questions with Twenty Eleven theme
- How to set the WordPress logo programmatically with PHP
- How to change logo by category
- get_header_image() causes “Prioritize visible content” issue in Page Speed Insights
- Logo custom width not implementing
- What exactly does “Posts page” do in WordPress?
- How do I make my function add variables/values to the $post object?
- Change comments form title on a page by page basis
- Get the title before comma
- “Can’t use function return value in write context” error
- Displaying Only Certain Tags in Loop
- Customized title tag for each page in pagination?
- WordPress automatically adds tags when pasting code, how to stop it?
- ACF: Only get first row of a Repeater Field
- WordPress with php 5.5 and zend opcache
- Woocommerce add to cart quantity buttons with AJAX
- How can I use wp_query to show all product data using just the products ID?
- WP add_action factory
- save imported posts as drafts
- How to show phpinfo() only in a new tab?
- Ajax load more posts with multiple tax query
- Ajax call not working
- Are there security or other issues with changing PHP time limit and max input vars?
- Auto-Select Parent Category as Primary
- How can I pass a custom/dynamic product to the Woocommerce cart?
- Long running queries
- comments sorting incorrectly across multiple pages
- auto-populating custom nav with all items from custom post type
- Irregular TTFB and server wait time response
- Saving plugin settings – ERROR: options page not found
- how to show only specific category for a template
- WP_Query fails despite having 1 post
- Download PDF after CF7 form submission
- 3 different times on my WordPress website
- Flexslider won’t work on WordPress
- Do I have anything to worry about when switching to a default theme to test for plugin conflictions?
- Unable to Find Space in Custom Function
- Unable to process php via shortcode
- Is it possible to create new user from external form using REST API?
- WP_Query: getting posts where custom field exists
- Foreach loop inside an array_merge
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Show the section only if custom taxonomy was chosen
- How to separate categories with commas?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Disable if there are no children – Woocommerce
- How to echo every parent page title?
- Alphabetically Ordered Category in WordPress
- change default RSS feed URL
- Limit posts when visited with mobile devices
- Gravity Forms merge tags in templates?
- PHP Warning: Missing argument 2
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Make a page (url) not cacheable [closed]
- mySQL queries are executed twice on wordpress website
- Populate custom field on publish or update
- Search page results conflicting logic – Search result caching?
- Insert PHP code in Text
- Site DOES NOT LOAD after 3.1 update
- How do you save the values from custom fields to a products data
- Order users by random not working?
- $_POST returning empty values
- var_dump() and print_r() display null in php
- add custom link to gallery images
- Sessions with WordPress
- How to Insert an advert banner for every third Slide using JS Composer Slider
- Dynamic Banner Text based on Subdomain
- How to programmatically set existing image in media library the featured image for a post in wordpress
- How can I copy an ACF field to AIOSEO field? [closed]
- How to find php variable of wordpress theme settings
- WordPress post insertion from PHP file
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- Use WP user status (logged_in) to manage access to independent application
- Date of last blog update for specific authors only?
- I was wondering if it’s possible to implement card.js on WordPress
- Display tag links on archive page?
- How can I add “.html” to the end of a single URL on a WordPress website?
- Adding an IF Function to Current Custom Category If has Child
- Else if Statement for Advanced Custom Fields [closed]
- Create a dynamic buddupress tab
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Accessing external database: ERR_INCOMPLETE_CHUNKED_ENCODING
- Would it be possible to route WordPress Through an MVC Application
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- jQuery vs. $ – Creating jQuery scripts in JavaScript in WordPress using External Libraries
- When I use rewind_post() it shows menu items in my loop
- Problem using explode inside add_shortcode() callback funciton [closed]
- How to post data to a word press site in case of a mobile app
- What languages were used to build WordPress? [closed]
- How to strip/remove all blank spaces at the beginning/end of a search string
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- why is kses removing semicolon from inline style?
- Add multiple HTML attributes to an Elementor button
- Customize the summary table of an order in the email
- How to sort custom sortable column by custom table value