WordPress.org

Ready to get started?Download WordPress

Forums

Featured Video Plus
Call to undefined function wp_read_video_metadata() in /var/www/vhosts/gdfiles (2 posts)

  1. Matt McFarland
    Member
    Posted 11 months ago #

    FULL ERROR:
    Fatal error: Call to undefined function wp_read_video_metadata() in /var/www/vhosts/gdfiles.net/hvac-hacks/wp-admin/includes/image.php on line 122
    Using my own theme (is based off wp 2012) - When users upload at http://www.hvac-hacks.com/share a video I get this error right at the POST.

    If it has something to do with my theme, here is the form I made:

    //Custom hvac hacks form
    function hvac_hacks_post_share() {
    	$current_user = wp_get_current_user();
    	if (debugMode) fb($current_user);
    	if (isset($_POST['submit_hvac_hacks_post'])) {
    		header( 'Location:/');
    		exit();
    	} else {
    
    		if ( 0 == $current_user->ID ) {
    			return '<h1>You must be logged in to submit a post.</h1>';
    		} else {
    			return '
    			<div id="hvac-hacks-post-loader" style="display:none;">
    			<h1 style="text-align:center">Uploading your post...<br/>Please do not close your browser until we are finished...<br/></h1>
    			<img class="aligncenter" src ="/img/486.gif"/>
    
    			</div>
    			<div id="hvac-hacks-post">
    				<form action="" method="post" enctype="multipart/form-data" name="hvachacks-post-form">
    					<fieldset>
    						<legend>Share Post</legend>
    						<input type="hidden" name ="hvac-hacks-post-user-id" id = "hvac-hacks-post-user-id" value="'.$current_user->ID.'">
    						<input type="hidden" name ="hvac-hacks-post-displayname" id = "hvac-hacks-post-displayname" value="'.$current_user->display_name.'">
    						<input type="reset" id="hvac-hacks-post-clear" style="display:none;">
    						<div class="hvac-hacks-post-category-wrap">
    							<label for = "hvac-hacks-post-category">Categories:</label>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="84">Blash from the Past</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="103">Condensate Nightmare Contest</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="82">Helpful Guides and diagrams</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="4" checked>HVAC Hacks</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="81">Memes</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="87">New Install</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="104">Questions</p>
    							<p><input type = "checkbox" name = "hvac_hacks_post_category[]" value="99">Videos</p>
    
    						</div>
    						<div class="hvac-hacks-post-title-wrap">
    							<label for = "hvac-hacks-post-title">Title / Caption</label>
    							<input type = "text" id = "hvac-hacks-post-title" name = "hvac-hacks-post-title">
    						</div>
    						<div class="hvac-hacks-post-content-wrap">
    							<label for = "hvac-hacks-post-content">Description / Question</label>
    							<input type = "text" id = "hvac-hacks-post-content" name = "hvac-hacks-post-content">
    						</div>
    						<div class="hvac-hacks-post-file-wrap">
    							<label for="hvac-hacks-post-file">Choose File</label>
    							<input type="file" name = "hvac-hacks-post-file" id="hvac-hacks-post-file">
    						</div>
    						<div class="hvac-hacks-post-submit-wrap">
    							<input type="submit" name="submit_hvac_hacks_post" value="Upload Post">
    						</div>
    					</fieldset>
    				</form>
    			</div>
    
    				';
    			}
    		}
    }
    
    add_shortcode('hvac_hacks_share','hvac_hacks_post_share');

    Now here is the POST method of the form (which results in an error)

    function submit_hvac_hacks_post(){
    	if (isset($_POST['submit_hvac_hacks_post'])) {
    		$isVideo=false;
    		$username = sanitize_user($_POST['hvac-hacks-post-displayname']);
    		$categories = $_POST['hvac_hacks_post_category'];
    		$title = sanitize_text_field($_POST['hvac-hacks-post-title']);
    		$content = sanitize_text_field($_POST['hvac-hacks-post-content']);
    		$file_tmp = $_FILES['hvac-hacks-post-file']['tmp_name'];
    		$upload_dir = wp_upload_dir();
    		$singleName = generateRandomString(21);
    		$newName = $upload_dir[path].'/hvac-hacks.com-'.$singleName;
    		if (debugMode) fb('Post Array: '.$_POST);
    		if (debugMode) fb('File Array: '.$_FILES);
    		if (debugMode) fb('Categories: '.$categories);
    		move_uploaded_file($file_tmp,$newName);
    		$image_types = array( 'jpg', 'gif', 'png', 'jpeg', 'bmp' );
    		$video_types = array( 'avi', 'mov', 'mpg', 'mp4', 'wmv','flv','mpeg' );
    		$user_file_array = explode(".", $_FILES['hvac-hacks-post-file']['name']);
    		$ext = array_pop($user_file_array);
    		$ext = strtolower( $ext );
    		if ($_FILES["file"]["error"] > 0)
    		  {
    		  echo "Error: " . $_FILES["file"]["error"] . "<br>";
    		  }
    		if ( in_array( $ext, $image_types ) ) {
    			exec('convert -auto-orient -verbose -format jpg '.$newName.' '.$newName.'.jpg');
    			exec('rm '.$newName);
    			if (debugMode) fb('temp file: '.$file_tmp);
    			if (debugMode) fb('new file: '.$newName);
    		}
    		$filename= $newName.'.'.'jpg';
    		if ( in_array( $ext, $video_types ) ) {
    			if (!in_array ($categories, "99")) {
    				array_push($categories,"99");
    			}
    			$filename= $newName.'.'.$ext;
    			$isVideo=true;
    		}
    		if(!isset($_FILES['hvac-hacks-post-file']) && $_FILES['hvac-hacks-post-file']['size'] > 0){
    			$filename = "/img/post.png";
    		}
    		$newPost = array(
    		  'comment_status' => 'open', // 'closed' means no comments.
    		  'ping_status'    => 'closed', // 'closed' means pingbacks or trackbacks turned off
    		  'post_author'    => $_POST['hvac-hacks-post-user-id'],  //The user ID number of the author.
    		  'post_category'  => $categories,  //post_category no longer exists, try wp_set_post_terms() for setting a post's categories
    		  'post_content'   => $content,  //The full text of the post.
    		  'post_status'    => 'publish',  //Set the status of the new post.
    		  'post_title'     => $title,  //The title of your post.
    		  'post_type'      => 'post',  //You may want to insert a regular post, page, link, a menu item or some custom post type
    		  'tags_input'     => 'hvachacks' //For tags.
    		);
    		$new_post_id = wp_insert_post( $newPost, $wp_error );
    		if (debugMode) fb('New Post ['.$new_post_id.'] Created');
    		if (debugMode) fb($newPost);
    		  $wp_filetype = wp_check_filetype(basename($filename), null );
    		  $wp_upload_dir = wp_upload_dir();
    		  $attachment = array(
    		     'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
    		     'post_mime_type' => $wp_filetype['type'],
    		     'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
    		     'post_content' => '',
    		     'post_status' => 'inherit'
    		  );
    		  if (debugMode) fb('File attachment: '.$attachment);
    		  if (debugMode) fb('guid: '.$attachment['guid']);
    		  if (debugMode) fb('Mime Type: '.$attachment['post_mime_type']);
    		  if (debugMode) fb('Title: '.$attachment['post_title']);
    		  $attach_id = wp_insert_attachment( $attachment, $filename, $new_post_id  );
    		  // you must first include the image.php file
    		  // for the function wp_generate_attachment_metadata() to work
    		  require_once(ABSPATH . 'wp-admin/includes/image.php');
    		  $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    		  wp_update_attachment_metadata( $attach_id, $attach_data );
    		  set_post_thumbnail($new_post_id,$attach_id);
    		  if ($isVideo) {
    			 add_post_meta( $new_post_id, 'video_url', $upload_dir['url'].'/hvac-hacks.com-'.$singleName.'.'.$ext, true );
    			if (debugMode) fb($new_post_id, 'video_url', $upload_dir['url'].'/hvac-hacks.com-'.$singleName.'.'.$ext);
    		  }
    
    	}
    
    }
    add_action('init','submit_hvac_hacks_post');

    Images work fine just as planned. How do I fix this????? Please help!

    http://wordpress.org/plugins/featured-video-plus/

  2. quwam
    Member
    Posted 10 months ago #

    Hi Matt.

    caution : This solution isn't correct but it can temporarily solve this problem.

    I got same problem today.
    I search about this function "wp_read_video_metadata()".
    then, I knew that This function exist in media.php.

    so that, I added to include "__DIR__/media.php"; for wp-admin/includes/image.php.

    Plz try it.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.