• im using get_attached_media to get the child of a video and im not getting any results but when you open the main video you can see that there is one.

    when i delete the child manually then add the main video to queue to recreate the child vids, it works. i get results from get_attached_media again.
    the problem is that i have over 9000 videos.

    is there a code to clear and delete all children of a video?

    or another way to get the child videos manually? so i can create a code to delete/fix them.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Kyle Gilman

    (@kylegilman)

    It’s possible there’s a better function to use than get_attached_media, but I’ll need to know more about what you’re trying to accomplish. What is the full code you’re using that doesn’t return any results? Were the child videos all created by my plugin? Were they made within the past couple years or longer than that?

    Thread Starter Metal_13

    (@metal_13)

    A year back i deleted the child videos to make space for my site but now i need them back. i used “get_attached_media(‘video’,$VideoParent)” to find and delete them.

    right now im using this code. not exact, i deleted some to make it shorter

    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) :
    <!-- pagination here -->
    while ( $the_query->have_posts() ) : $the_query->the_post();
    
    UI: the_post_thumbnail ----- the_title() ---- Main_Video_Link --- child_link(if the is)
    
    //GET VIDEO PARENT ---------
    $media = get_attached_media( 'video', $post->ID );
    foreach($media as $attachment){
    if(!$VideoParent){
    $VideoParent = $attachment->ID;
    if(get_post_mime_type($attachment->ID) != 'video/mp4'){
    echo 'FileType:'.get_post_mime_type($attachment->ID).' [Added to queue] ';
    update_post_meta ( $post->ID, 'error', 'not_mp4' );
    echo '[error:'.get_post_meta ( $post->ID, 'error', true).']';
    kgvid_cron_new_attachment_handler($VideoParent); //ADD TO QUEUE
    }}}
    
    //CHECK IF QUEUED
    $Queue = kgvid_get_encode_queue();
    foreach ( $Queue as $video_key => $video_entry ){
    if($VideoParent == $video_entry['attachmentID']){ echo ' [QUEUED] ';}
    }
    
    //GET VIDEO CHILDREN  --------- START\\
    $media = get_attached_media( 'video', $VideoParent );
    
    if($VideoParentHeight > 360 && count($media) == 0){ 
    update_post_meta ( $post->ID, 'error', 'no_child' );
    echo '[error:'.get_post_meta ( $post->ID, 'error', true).']';
    }
    
    //GET VIDEO CHILDREN - RESOLUTION (Height Meta) --------- START\\
    foreach ( $media as $attachment ){
    $attachment_meta = wp_get_attachment_metadata($attachment->ID);
    $VideoHeight = $attachment_meta['height'];
    echo '<div class="NLChangelog" style="width:90px;">';
    echo '<a target="_blank" href="/wp-admin/post.php?post='.$attachment->ID.'&action=edit">'.$VideoHeight.'<b>p</b></a>';
    echo '</div>';
    }
    
    //Move to next page every X secs
    $URL = '/convert-all-videos/page/' .$EndNumber;
    $page = $URL;
    header("Refresh: $RefreshTimer; url=$page");

    what i want to do is like a fix/cleanup page similar to that code.
    WP_Query 5 videos per page and check them if it’s converted and has a 360p child. then save the 360p in post_meta so i can pull it for streaming.

    i have 2 video formats, replaced original and 360p.
    i would like to stream only the 360p and use the original for backup or download.

    Plugin Author Kyle Gilman

    (@kylegilman)

    I’m more than a little confused about this whole thing. What function did you use when you deleted the videos last year? It looks like I never use get_attached_media in my plugin for reasons I don’t recall, so it’s worth trying a get_posts query instead.

    $args = array(
        'numberposts' => '-1',
        'post_parent' => $post->ID,
        'post_type' => 'attachment',
        'post_mime_type' => 'video'
    );
    $media = get_posts( $args );
    Thread Starter Metal_13

    (@metal_13)

    i’m getting the same results. they only show up if i reconvert them or when the video is a new upload. maybe they only exist in the main video’s meta? how do you store them on the main video?

    i checked my old files. looks like i remembered wrong, i used this code to get them.

    $args = array(
    'post_type'        => 'attachment',
    'post_status' => array( 'any' ),
    'paged' => $paged,
    'posts_per_page'      => 5,
    'post_mime_type' => 'video',
    'author__in' => '-0',
    'post_parent' => '0',
    );
    $the_query = new WP_Query( $args );
    Thread Starter Metal_13

    (@metal_13)

    the only fix i could think of right now is to reattach the video as new.
    copy video1 as video2, delete video1 then attach video2 to post.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Video Child not detected’ is closed to new replies.