Have a look to wp_get_attachment_image_src(), which gives precisely data you need (URL and dimensions). Which help to figure out your problem.
sample code
$image_attributes = wp_get_attachment_image_src( $attachment_id = 10 );
if ( $image_attributes ) : ?>
<img src="https://wordpress.stackexchange.com/questions/302831/<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
The return section gives keys, but the function just returns indexes as.
array{
[0] => url,
[1] => width,
[2] => height,
[3] => is_intermediate (boolean)
}
We should make it clearer what is returned by this function. And some description or a link to explain is_intermediate.
Related Posts:
- Missing feature image link function
- Add multiple custom fields to the general settings page
- Is it possible to remove the “standard” post format?
- Woocommerce add to simple product attribute programmatically [closed]
- Issue with get_theme_mod returning a blank value instead of the saved value
- How to remove row-actions from pages table?
- Get recent posts with thumbnail
- Modify search function in WordPress (TwentyTwelve)
- Add options to featured image
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- How to fix a theme with page.php Default Template that accidentally deleted?
- How do I change parameters without changing the core
- Problem with extract() with custom shortcode
- add sidebar area to header of child theme
- Setting featured image with function, 1 part not working
- Theme-Config tab in admin Pannel?
- Creating loop within functions.php
- adding custom classes for tables
- Pass Shortcode Attribute to footer Script
- img width and height attributes being set by get_the_post_thumbnail
- PHP files included in functions.php don’t seem to work
- Get the 5 lastest Featured Posts from a category
- How Can I Expand the WordPress Customize window without any Plugin?
- Set quantity of woocommerce product on page visit [closed]
- wp_dropdown_categories and custom attribute
- Getting Featured Image Caption to Only Show if Populated
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Add Featured image column into wordpress admin on pages AND posts
- Automatically wrap multiple images in div
- Ajax not working properly
- Post thumbnail not showing in WP admin area for custom post type
- Backstretch.js and thumbnail sizes to reduce loading time
- Include default functions and methods
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- How to stop twenty fifteen theme from cropping featured images?
- How can I modify all existing tags while keeping the urls themselves?
- show first 3 thumbnails of posts in different sizes [closed]
- Unable to login using username
- Set spesific size of featured images
- different style sheet for just one page template
- It does not work concatenation in function.php
- Condition OR for current user ID
- is there a way to remove featured image from blog page and single page
- Can’t locate custom image sizes defined by child theme
- login_headertitle is deprecated since version 5.2.0
- Add attribute only to first image of every post via functions.php
- Different favicon on different pages
- The_content and Preg_replace in loaded Iframe [closed]
- two search forms on the same page
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- New checkbox in custom widget isn’t saving data
- how to display a page before the home page
- loginout function customization
- Show Featured Image in else statement
- How to add icon over specific thumb
- Featured Image keeps cropping
- Function to check if custom page is used by page?
- show all the posts thumbnails
- struggling with syntax for the_post_thumbnail();
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- How to remove font awesome from loading in wp theme
- Which filter fires upon setting a featured image
- Header menu aligned right on all pages except for single-post page [closed]
- Can You Set A Minimum Image Dimension For Resizing Images?
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- Shortcode to insert default text and change one word throughout it?
- I want to customize the_posts_navigation function by replacing prev and next with images
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- WordPress Ajaxifying not working properly
- WordPress function with attribute pass to template
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Printing medium sized image
- Sticky – Featured Image
- Adding A New Widget to WordPress Disables the Existing Widgets
- Help! Need a different logo on my main page from my other pages
- Frontend Feature image upload not work
- Display page number on custom page title function
- Slider Thumbnail Size Issue [closed]
- How to replace words in my posts and saved new words
- How do I integrate my Child Theme into a Custom Template?
- Shortcode to eliminate and replace with
- Remove Featured Images from Posts Older Than a Certain Date
- Add functionality to post editor
- Set thumbnail from URL, by grabbing image in functions.php
- add_theme_support not outputting thumbnails
- child_of not working while searching
- Why does modifying my functions.php file always result in a server error
- Remove snippets of JS from core
- Image width issue in IE [closed]
- Explode Array from Repeatable Custom Field
- image_size with respect to aspect ratios
- WordPress Custom wp mail template return full template
- Problem with removing characters “<” – WpAllImport
- How to create a post without link in wordpress?
- multible shortcodes (for differnt values) with one function
- post_row_actions filter from parent theme not executing in child theme