Had the same issue last week and here is what i did:
if (has_post_thumbnail())
//if the post already has a post thumbnail then just use that
the_post_thumbnail($size="post-thumbnail", $attr="");
else{
//if not then convert the custom field to the post thumbnail and display that
$at_url = get_post_meta($post->ID, 'image', true);
$at_id = get_image_id_by_url($at_url);
delete_post_meta($post->ID, 'image');
if ($at_id){
set_post_thumbnail($post, $at_id);
the_post_thumbnail($size="post-thumbnail", $attr="");
}else{
//else just display a default image or not :)
}
}
Related Posts:
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- How can I migrate all of my custom field thumbnails to the built-in post featured image?
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- Adding a custom field or metabox to the post-thumbnail widget?
- Deleted pages showing up when querying for child pages
- Add url from Custom Field as ‘Featured Image’. Code not working
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- How to mass update custom fields for more than 20k posts
- how to make nsfw post with thumbanil
- Can I use a Custom Field as the Featured Image URL?
- Getting the Featured image URL and inserting it as Custom Field on Post update / publish
- User customising position of WordPress Featured Image
- Set featured image from custom field URL
- Custom field as featured image caption
- WP Insert post with post_thumbnail
- Custom field image to Featured Image
- Selectively hiding or allowing thumbnails of featured images on front page
- use custom field value as featured image
- Can you generate a featured image from two images from custom fields?
- Use a different catalog image than the featured image
- Automatically set the_post_thumbnail to Custom Field Value
- Related post thumbnail not showing up
- Post thumbnail size for custom field only
- How to mark a image attachment as background image?
- Custom field for image, not showing image!
- Show/Hide Featured Image or replace it with custom field [closed]
- Crop custom image size vs actual size
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- explode array within shortcode
- Can I count the number of users matching a value in a multiple value key?
- Display post_object content using Advanced Custom Fields plugin
- Remove old custom field after import
- Arrange custom fields with drag and drop?
- Allow user to create instances of custom field
- get_pages sort alphabetically by meta value
- 2 orderby in wp_query with 2 custom fields
- Compare meta_query decimals not working right
- Using Custom Function With Advanced Custom Fields
- custom field with total count of Facebook likes, comments and shares
- How to show custom field’s value under post/page title in wp-admin
- Query on custom field count?
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- Custom field value based on other custom field values
- Sorting posts by custom fields in meta_query
- Delete all custom fields at once?
- get_post_meta just returns Array
- Sorting posts ordered by custom field value
- Odd PHP Code To Display HTML Of Meta Box [closed]
- strtotime and custom field value
- Unique Post Meta Values
- WP 3.1 meta_query for multiple custom field values
- Better way to save image in custom field
- Jetpack post types Portfolio or Testimonials support for custom fields?
- Merge Multiple Custom Fields into one New Custom Field for Searching
- Is there a better way to list all database terms alphabetically?
- Select multiple images from custom field
- Unique meta_key with array value vs repeated meta_key with single values
- Custom Field 101
- custom field (video/audio url) and embed functionality
- Allow only one post with specific meta value
- Querying posts by latitude and longitude to build a Google Maps with several markers
- How to display childrens custom fields?
- Attach images to posts using custom fields (just paths to images already uploaded)
- how to display custom fields of post on a web page
- Changed PHP handler to DSO – weird custom fields problem [closed]
- How to fill custom fields with brackets in their key with add_post_meta()?
- Is there a way to set default custom fields when creating a new post?
- Front-End User Profile
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- put saved metabox values back into fields and then display on the front end
- Custom field to array?
- How to sort by custom field value?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- How to query posts by month based on date custom field?
- Custom field bug in WordPress 3.2
- Change word in woocommerce product category custom field
- get posts based on non-single metadata
- Problem with revisions only returning four results
- How to save multiple values with same meta_key, each value linked to another tag id
- Add forms dynamically in admin pages?
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- how can i show WordPress custom field data to my short code?
- searching by keywords in post’s metas or pagination links problem
- Permanently show Custom Fields in Editor
- open modal window
- a lot of custom fields
- Hide custom fields by user’s role
- Retrieve Google API JSON data and store as WordPress Custom Fields
- update meta field value after
- If metabox fields has content display content
- Display Data From This Custom Media Upload Meta Box?
- Custom fields and auto save
- Save values generated via API as custom meta fields
- Load code for custom fields only on admin pages?
- Custom field in a shortcode?
- Exclude empty fields from custom field calculation (Average)
- How do i output images from URL’s added to the same custom field key
- Filter Query Post by Custom Fields(by date)