Skip to content
Snippets Groups Projects
Commit 8cac1fd2 authored by ale's avatar ale
Browse files

Fix some debugging; accept all content except video

Video is skipped due to the (current) lack of ffmpeg in wp-mat-server.
parent 1ee15277
Branches
No related tags found
No related merge requests found
Pipeline #54126 passed
......@@ -3,7 +3,7 @@
* Plugin Name: wp-mat
* Plugin URI: https://git.autistici.org/noblogs/wp-mat
* Description: Process uploaded files through MAT
* Version: 0.0.11
* Version: 0.1.0
* Author: Autistici/Inventati
* Author URI: https://www.autistici.org/
* License: MIT
......@@ -15,11 +15,13 @@ if (!defined("WP_MAT_ENDPOINT")) {
}
// Check if the mime type is one of those we want to clean up.
// Use a blacklist, currently empty. Send everything by default
// except video.
function wp_mat_is_supported_mime_type($mimetype) {
if (substr($mimetype, 0, 6) === "image/") {
return true;
if (substr($mimetype, 0, 6) === "video/") {
return false;
}
return false;
return true;
}
// Make a POST request to the MAT service with the uploaded file and
......@@ -51,10 +53,7 @@ function wp_mat_issue_request($path, $mimetype, $output_path) {
}
function wp_mat_handle_upload_prefilter($file) {
error_log("wp-mat: called with file=".json_encode($file));
if (isset($file['error']) && $file['error']) {
error_log("wp-mat: upload has error set to ".$file['error']);
return $file;
}
......@@ -97,7 +96,10 @@ function wp_mat_handle_upload_prefilter($file) {
add_filter('wp_handle_upload_prefilter', 'wp_mat_handle_upload_prefilter');
function wp_handle_upload_error(&$file, $message) {
error_log("wp_handle_upload_error: ".$message);
return array( "error" => $message );
// This is generally useful for debugging.
if (!function_exists('wp_handle_upload_error')) {
function wp_handle_upload_error(&$file, $message) {
error_log("wp_handle_upload_error: ".$message);
return array( "error" => $message );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment