• Resolved emanradin

    (@emanradin)


    Hi,
    I’m using a VPS with FFMPEG installed and my problem is when uploading a video, the thumbnail that is generated is being set to featured image on the video file itself, not on the post. However, I’ve already set “attach thumbnails to: Post” but it’s still setting to the video file. Is there something I need to do differently?

    Note:
    – It works perfectly on localhost / MAMP
    – In-browser thumbnails set to: OFF (tried both but still no go)

    backend hosting settings:
    – upload_max_filesize: 6M
    – memory_limit: 64M

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter emanradin

    (@emanradin)

    Also note (very important):
    Everything works as expected when posting from admin backend, but not from the frontend which is my goal for using this plugin.

    Thanks again

    Thread Starter emanradin

    (@emanradin)

    Okay, I think I got a work-around.

    Basically, all I wanted was to show a poster for my video, but in my template I was trying to pull the featured-thumb that didn’t exist with:

    wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');

    So, since the featured-thumb isn’t attached to the post, but rather the video file, I managed to go through the pages and found you posting this code:

    get_post_meta($attachment->ID, "_kgflashmediaplayer-poster", true);

    To be used to grab the poster

    So for now this works ??

    Plugin Author Kyle Gilman

    (@kylegilman)

    That’s a good solution, but most people aren’t able to come up with custom solutions like that so it would be nice if the featured image were set correctly. The problem (and I’ve seen it happen before) is that the frontend uploader creates the attachment first and then creates a post and sets it as the attachment’s parent. The thumbnail process starts as soon as the video attachment is created, so in some cases, at the time the thumbnail is created, there is no post to set the featured image on. However, if you have a very fast server with no traffic, like your localhost testing machine, the database operations are usually finished before the relatively slow process of creating the thumbnail, and there is a post ready to set the featured image on.

    I hadn’t come up with a solution before, but now I’m thinking I could create a reminder in WP_Cron after the automatic thumbnail is created if there’s no post_parent yet.

    Thread Starter emanradin

    (@emanradin)

    Yes your right maybe in the future, but I guess it will do for now.
    I appreciate the work you do and all your support.

    Plugin Author Kyle Gilman

    (@kylegilman)

    In version 4.6.14 I added a reminder in WP_Cron to check for posts that are created after an automatically-generated thumbnail, which I hope will solve your featured image problem. Let me know if you’re still having this problem after the update.

    Hi,
    My customers can upload videos from frontend. How I can set the featured image of post with generated thumbnail?

    Plugin Author Kyle Gilman

    (@kylegilman)

    Are you having the same problem as the OP or are you asking for instructions to setup the plugin? Do you already have FFMPEG running on your server and everything is working except the featured images?

    Hi Kyle, Thank you for the reply.
    Plugin work correctly and I have FFMPEG. Thumbnail generate correctly and attach to post/video.

    I would like that Thumbnail attach to frontend submitted post/video

    Plugin Author Kyle Gilman

    (@kylegilman)

    You’re running version 4.6.14 of my plugin? As I explained to emanradin, people seem to have problems with frontend uploaders and featured images. The frontend uploader for some reason doesn’t trigger the necessary hooks in WordPress to tell the plugin which post is associated with the video. What plugin are you using for frontend uploading?

    I run 4.6.14 of your plugin.
    For frontend uploading I’m using cactus video plugin/contact form 7 form (videoPro theme).

    This is the code:

    // upload video thumbnail
                if(isset($posted_data['video-thumbnail']) && $posted_data['video-thumbnail'] != ''){
                    $file_location = '';
                    if(!$contact_form_7){
                        $file_location = $posted_data['video-thumbnail'];
                    } else {
                        $file_name = $posted_data["video-thumbnail"];
                        $uploaded_files = $contact_form_7->uploaded_files();
                        $file_location = $uploaded_files["video-thumbnail"];
                    }
                    
                    $upload_dir = wp_upload_dir();
                    $image_data = file_get_contents($file_location);
                    $filename = basename($file_location);
                    if(wp_mkdir_p($upload_dir['path']))     $file = $upload_dir['path'] . '/' . $filename;
                    else                                    $file = $upload_dir['basedir'] . '/' . $filename;
                    file_put_contents($file, $image_data);
    
                    $wp_filetype = wp_check_filetype($filename, null );
                    $attachment = array(
                        'post_mime_type' => $wp_filetype['type'],
                        'post_title' => sanitize_file_name($filename),
                        'post_content' => '',
                        'post_status' => 'inherit'
                    );
                    $attach_id = wp_insert_attachment( $attachment, $file, $new_ID );
                    require_once(ABSPATH . 'wp-admin/includes/image.php');
                    $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
                    $res1 = wp_update_attachment_metadata( $attach_id, $attach_data );
                    $res2 = set_post_thumbnail( $new_ID, $attach_id );
                }
    Plugin Author Kyle Gilman

    (@kylegilman)

    Is that the code for uploading a video thumbnail using your commercial plugin? I don’t need to know how video thumbnails are uploaded by that other plugin, since my plugin creates them on your server so it doesn’t use that form. The question is, when a video attachment is created by this plugin, how is it associated with a post? My plugin expects to find a post_parent in order to set the featured image but it seems like there’s no post_parent assigned to the video at the time the thumbnail is created.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Thumbnail not automatically setting as featured image’ is closed to new replies.