You want wp_get_attachment_image_src()
:
if ( $src = wp_get_attachment_image_src( $attachment_id, $size ) ) {
echo $src[0]; // URL
echo $src[1]; // Width
echo $src[2]; // Height
}
Related Posts:
- How to show scaled featured image in template?
- Force all images to full size in page template
- ACF image field to WordPress featured image
- second featured post not displaying on page [closed]
- How to use Class
in Java? - Missing feature image link function
- Get name of the current template file
- How do you find out which template page is serving the current page?
- How to change the default registration email ? (plugin and/or non-plugin)
- How do I get the size of an attachment file?
- Filter to remove image dimension attributes?
- How to get image title/alt attribute?
- User-friendly cropping of post thumbnails?
- Is there any way to use get_template_part() with folders?
- How can I make add_image_size() crop from the top?
- No Thumbnails Generated
- How to disable WordPress from creating thumbnails?
- add_image_size() for specific Post Types
- Stop wordpress from hardcoding img width and height attributes
- Programmatically get images by URL and save in uploads folder
- How do you get the post thumbnail size?
- set_post_thumbnail_size vs add_image_size
- Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?
- Minimum Dimensions Requirement for Featured Image?
- The the_post_thumbnail without srcset?
- Generate Thumbnails only for Featured Images
- Get the first image from post content (eg.: hotlinked images)
- How to get all featured image sizes and their URLs?
- How to disable generation of default image sizes for some custom post types?
- How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)
- How can i change email template for new user
- Any advantage to using get_header() over include(‘header.php’)?
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Use [embed] filter in template files
- How to automatically add rounded corners to thumbnails?
- How do I change/modify the_post_thumbnail(); html output?
- What’s the purpose of the paged.php file?
- Display thumbnail only if requested size exists
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- How do you access the Product Short Description in a WooCommerce email template? [closed]
- Download an image from a webpage to the default uploads folder
- Prevent comments_template() to load comments.php
- What’s the best way to use the Featured Image for responsive web design?
- the_post_thumbnail responsive srcset not populating with custom image size
- Is there a way to list all used/unused WP templates?
- Page editor missing Templates drop down
- Print WordPress template filename(s) for debugging
- How to change image type for specific size?
- How to add multiple image sizes of the same size with add_image_size
- New image size version only for the Featured Image file
- Can’t extract and set SVG dimensions
- How to force TinyMCE in WordPress to replace newlines with tags and not with
- How to find the posts page (home page) programatically
- WooCommerce: Change template for single product page
- View WordPress page template usage (or unused)
- Is there a hook which fires after all thumbnails are generated?
- is it possible to replace the use of gd_lib with imagick or ImageMagick?
- How to edit contents of dynamic_sidebar()?
- How to check if a shortcode exists?
- Where is get_header(‘shop’) file in Woocommerce templates
- Custom templates folder
- What is the link to my default “archive” page?
- Featured image shortcode
- How to find attachment by it’s name?
- How to get slug of current category in taxonomy template?
- How to show a under construction page for a domain but still be able to work on index.php?
- Change the name of the ‘Default Template’
- Customizing get_the_excerpt() to specific length and “Read More” output.
- How to Rename a Template File?
- How to get Images included in Post
- get page templates
- Echoing Elementor page content in template, but it doesn’t get styles and some widgets are missing
- Using WordPress templating for HTML emails
- Change WordPress image URLs via filter
- get_the_post_thumbnail_url with an unregistered size
- Getting custom-sized featured image’s URL?
- Cropped featured image replaces original image in gallery
- Loading partial templates with AJAX/PJAX
- WP frontend output of custom textarea fields not respecting line breaks. In admin it’s OK
- How do you check if a WordPress template file exist?
- Image Scaling using get_the_post_thumbnail issue in WordPress
- set_post_thumbnail_size in percent, not pixels?
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Load entire NextGEN gallery from single thumbnail?
- I put my blog on a subpage, how do I get page title?
- Remove title attribute from images
- A special single page templates for posts under a category and all its child category
- Showing a placeholder/default img, if no featured image is set
- Insert an image into a post by API
- Custom reset password template after forgot password request
- Outputting Canonical Resource URLs Across a Multisite Network?
- Gravity Forms Custom Templates [closed]
- Child Theme: how to override variables?
- How to create thumbnails with a fixed width, so all of them will have the same width?
- Featured image with the same height thumbs returns wrong thumb
- Where to store some per-template preferences?
- How to limit number of images being printer out in “Set Featured Image” pop up?
- How to change the naming of the resized image files
- How might I retrieve a featured post image from an external WP site and display it as a link back?