Is there a way to automatically set an uploaded image as the Featured Image? I found some code to place the image as a thumbnail, so that solves half my problem. But I'd like it to be the featured image as well.
Thanks in advance!
Donna
Is there a way to automatically set an uploaded image as the Featured Image? I found some code to place the image as a thumbnail, so that solves half my problem. But I'd like it to be the featured image as well.
Thanks in advance!
Donna
Currently there is no built in way to set the image uploaded as the feature image. It is a feature we plan on looking into how we can implement in a future release. It would be possible to do now but would require a customization and WordPress development knowledge to do so.
@guildmaster here is what I am using (please correct me if this is not the best practice)
add_action("gform_post_submission", "post_submission_handler");
function post_submission_handler($entry){
global $wpdb;
$results = $wpdb->get_results($wpdb->prepare(" SELECT l.*, field_number, value
FROM wp_rg_lead l
INNER JOIN wp_rg_lead_detail ld ON l.id = ld.lead_id
WHERE l.id=%d
ORDER BY l.id, field_number", $entry["id"]));
foreach($results as $result){
$post = $result->post_id;
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent='.$post );
if ( empty($images) ) {
// no attachments here
} else {
foreach ( $images as $image ) {
$featured =& add_post_meta($post, '_thumbnail_id', $image->ID );
break;
}
}
}
}
Thank you both!
blrfurther do you use that code in the post template?
@ guildmeister - Can you please point me to the code that you found to add the image as a thumbnail? Thanks!
@Kirsten Sorry for the delay in replying I've not been getting notifications of updates to the posts. Here is the code I used in a Post Fields Body widget. Under the Properties of that widget you make sure the Create Post Content Template box is checked. The first thing I have in the field that will create the post content is this:
{Main Image:4:thumbnail:left}{Description:3}
The numbers may be different for your form. This code will put the image as a thumbnail, left-aligned with the body text (I called my body widget Description) wrapped around it.
I hope that helps.
Doesn't work with WP 3.2. Go here for the fix:
http://www.gravityhelp.com/forums/topic/support-post-thumbnails