What about using wp_get_attachment_image_src
?
Using wp_get_attachment_image_src
:
$src = wp_get_attachment_image_src( $img_id, 'thumbnail' );
$src = $src[0]; // Grabs only the URL ($src[1] = width of image, $src[2] = height of image)
Related Posts:
- Change code to display image attachment page
- How To Retrieve An Image Attachment’s Alt Text?
- Programmatically get images by URL and save in uploads folder
- getting attachement images src and add classes
- Check if post has attachments (not image)
- Changing attachment urls?
- Validate alt text for attachments?
- Applying automatic link class to images embedded to posts
- get post attachments of a particular size
- Change image link: wp_get_attachment_link
- Making images from single.php pointing to an attachment .php template
- wp_get_attachment_image_src always returns false
- Exact image sizes
- Change default URL of image attachment
- attachment url rewrite
- Get the size (size in Kb or MB) of an featured image?
- Insert custom ID into wp_get_attachment_link
- query attachment images … if no attachments -> get attachments of parent page?
- Edit default image attachment size
- Attachment 0×0 size error [closed]
- Add image attachment to post via coding?
- How to change image url?
- Link all WordPress images size
- Removing width and height attributes from wp-get-attachment
- Get post attachment images dimension and use in embed code
- use wp_get_attachment_image() to show attachments
- Adding width and height to wp_get_attachment_image_src
- media_sideload_image with rewritten urls?
- Display attachment resolution size
- How to check if there is image title, caption, description?
- How to remove attachments size attribute [duplicate]
- How to redirect ‘file url’ to ‘post url’ i.e. in attachment.php
- Check what attached image size is used
- How do I get all attachments that are used in the current post, not just the children?
- Clean up images, delete unused image sizes attached to a post type
- Get title of post image is attached to
- Correct attachment size
- Post Gallery list attachments except the one used as post thumbnail
- Get image attachment to a post outside the loop?
- How to get image URL from media_sideload_image?
- How do I intercept and modify the functionality of wp_get_attachment_image()?
- Unable to get wp_get_attachment_url to show
- Get Attachment Image Class by attachment id
- Possible to add “Even/Odd Classes” to image attachments via wp_get_attachment_image?
- How to replace post image url before posting using api?
- changing the default picture size link url
- Get an image from the media library. Struggling with the code?
- How to view exact image dimensions of a media in Admin view?
- Filter not applied to all image sizes
- wp_get_attachment_image_src calling wrong location
- Get attachment URL from attachment Link in WordPress
- Display setting ‘size’ not available in image settings modal
- Hide Image Container if No Image Attachments
- Setting name of attachment URL
- Incomplete attachment page
- How to retrieve “custom url” from image attachment in wordpress
- Retreive tags from attached post for media on page
- list of attachments: wp_get_attachment_link works, wp_get_attachment_image does not
- What is the most efficient way to retrieve a group of image URL’s from different attachment ID’s of a specific crop size?
- get_image_tag filter not working
- Change attachment inside the_content using filters
- How to manage attachment relationships for specific posts in WP 3.5+
- remove missing image attachments
- custom fields for attachments?
- Get attachment ID of author_meta image – Attachment Metadata
- ID of images from gallery
- Adding attachment file name to email link
- How to allow specific extensions and file size to wp_mail attachment?
- Return Attachments from Custom Post Type
- Adding class to next/prev image link in attachment.php
- How to add multiple checkbox elements to media attachments?
- Get attachment next and previous by author only
- Converting Attachment to Images?
- Multiple images in one attachment page
- Don’t show attachments if they are inserted in post
- Uploaded attachment not set as featured image
- How to get $attachment->ID in custom functions
- How to test if there are no more previous or next image on attachment page?
- how to get attached file url for current post?
- How to list all images used on a specific page?
- All attachment pages give 404
- Scrape a webpage for image and add it to post
- Automatically deactivate link for attachments
- Getting attachment post using wp_get_attachment_link
- wp_mail Allow Remote Attachments from CDN
- Get all image in media Gallery with alt/title?
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Zip a file and add as attachment
- Setting an image as post header (not featured image)
- Get “Image CSS Class” value from the Advanced Options section
- How to restrict users to only access their own media files in wordpress
- wp_mail doen’t send mails whit attachment
- How To Query All Attachment Images Found In Post Galleries
- When inserting attachments into a blog post, how can I get WordPress to use the full filename with the extension?
- Is there a way to add Reattach and Unattach links in image gallery?
- Post images not displaying as attachments
- Broken image URL
- Custom Fields, Media uploader, Attachments
- Remote Image (from URL) as Media Library element
- Media library upload hook