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.