Try this first
Make sure that the post in question has its Featured Image (formerly Post Thumbnail) set.
Then…
Going by our comment thread, here’s something else to try.
function gangmei_get_the_post_thumbnail_url($post_id = NULL) {
/*
* global $id;
* $post_id = (NULL === $post_id) ? $id : $post_id;
* $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
* $src = $src[0];
*/
global $post;
if( NULL === $post_id ) {
$post_id = $post->ID;
}
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ) );
if( !is_array( $src ) && ! $src ) {
return false; // there's an error somewhere
}
return $src[0];
}
Related Posts:
- Set default image sizes in WordPress to hard crop
- Remove images (files) that were generated when using add_image_size()
- Displaying images from external RSS feeds?
- Why should I use “Organize my uploads into month- and year-based folders” option? (Cons/Pros)
- Which action hook can I use when a featured image has been selected
- Displaying images with relative paths in the editor
- Fixing external image urls
- Image resize with image url
- Preview Image Path in Admin Section
- The WordPress Gallery, Grabbing The Link and Images?
- Featured Images on Front Page
- Show prev and next post links for parent post of current image in attachment page?
- could not upload image in media library
- Check if page/post has any anchors that link to an image jpg/gif/png
- How to check if user is uploading/setting an image as a featured image?
- hardcrop images in gutenberg “latest posts” block
- Use Gravatar as fallback image if no local image is not found
- add the post as canonical for attachment page wordpress
- Retrieving an alt tag from a custom field
- Exclude featured image from gallery in wp-admin
- Trying to create a mouseover effect in html using Gutenberg editor
- wordpress get gallery images title
- How to fix “.webp” being auto-added to the end of image urls
- Customizing the attachement page to show rest of all images in a gallery from post
- Is it possible to change ‘Link to’ in all images in all articles?
- Is it possible to put images as url in document [closed]
- Creating ‘required’ fields in the ‘add media’ window
- Importing images results to wrong folder structure
- WP keeps looking up post thumbnail on https even though wp-config says http
- How to post a mosaic of an image gallery instead of the entire gallery inside a post’ [closed]
- using media_sideload_image with a file from theme directory
- Upload image without media-upload [duplicate]
- Tinymce and uploading local pictures
- Time Based change of image
- WordPress shows my picture in admin bar
- Using jQuery to automatically add class only to gif images in WordPress database [closed]
- Modify RSS – remove image and add text
- how to get image full path from WP_Post Object?
- Featured Image problem with resizing
- WordPress Image Scaling Quality
- Create a post from every image in my media gallery
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Is there a wordpress filter to edit the markup of inline images?
- Not seeing text alignment option in Image block
- wp_get_attachment_url images in wrong order [closed]
- Migrated site – Images have 404 error
- Alt text not showing up
- Show (print) featured image all dimensions (height, width)
- Speed Up Website With High Resolution Images
- Removing Images from a WordPress Post
- How come the images arent loading properly?
- How to use the thumbnail size with catch_that_image
- Random Image Script Working but Want to Avoid Duplicates
- HTML Img with data:image src gets sanitized in admin?
- Can’t find image to remove
- How to add a custom class to all the images for a page only?
- Not able to retrieve image id from sibling site within a switch_to_blog
- How to display a warning when an uploaded image is too small?
- How to link image in WordPress – Elementor when certain element does not offer that option?
- Large uploaded images not resizing?
- How can i place featured image after h2
- How to generate alt attributes with php / filters?
- Custom image size not displaying with wp_get_attachment_image()
- unsharp thumbnails after uploading image
- How to delete original image file after upload and resize
- WordPress After migration some images src is empty
- Access html element in media modal with jQuery
- Jetpack Lazy load images fade in
- add alt text to images loaded from json with media_sideload_image
- How can I add “alt” tag to element?
- How to make image uploads default to full size?
- WordPress images programatically display error
- Recovered WordPress installation (on localhost) links broken and images not showing
- Image is missing on site homepage
- Put image onto header
- Media sizes do not appear
- Changing current post image uls with a function
- Display images in template file
- How to watermark wordpress images from wp-content/uploads folder with htaccess and php?
- How to display every pictures from all the posts on one page?
- How to add multiple images in a page
- Only User Upload image Http Error
- Retrieving Image Storage path
- See the all uploaded images of a user as an admin
- how to display all images from their siblings/ from same parent?
- Define Folder to save Images
- Specify what to do for a specific image number of the post
- adding images to wordpress pagination?
- Custom filename when pasting an image from clipboard
- WordPress Bootstrap dynamic carousel showing images separately not as carousel
- How do you change all images dimensions to have the same size?
- Delete all thumbnails & regenerate them?
- Can I turn an image into a button?
- Why are some SVG-images not visible in my footer?
- How To Get Feature Image from Blog in Same WordPress Multisite Blog on the Parent Blog?
- WPALLIMPORT Exporting images from repeater field [closed]
- What does WordPress media uploader do to image files on upload?
- Gutenberg block HTML image rendering override
- image_get_intermediate_size always returns false
- Change of displayed images for webp versions