Specified file failed upload test. wp_upload_handle

The error you are seeing is coming from wp_handle_upload(): // A properly uploaded file will pass this test. There should be no reason to override this one. if ( $test_upload && ! @ is_uploaded_file( $file[‘tmp_name’] ) ) return call_user_func($upload_error_handler, $file, __( ‘Specified file failed upload test.’ )); I am not sure about your context, but … Read more

post_id missing from the wp-admin file upload request

Ok this seems to have fixed it: function wp_plupload_include_attachment_id( $params ) { global $post_ID; if ( isset( $post_ID ) ) $params[‘post_id’] = (int) $post_ID; return $params; } add_filter( ‘plupload_default_params’, ‘wp_plupload_include_attachment_id’ ); This preprocesses the uploader $params and makes sure the post_id is included. Taken from here: https://core.trac.wordpress.org/attachment/ticket/22085/media.php.patch

Incremental number handling on duplicate file names

The number is added in wp_unique_filename() in wp-includes/functions.php. You can prevent it by hooking into ‘sanitize_file_name’ and setting another file name. You can find such functions and filters by following the code with your IDE. Most IDEs make functions clickable so you can go from their call to their declaration. Here is an example from … Read more

Filter medias from the Media Uploader (wp.media) modal with a post meta

Simplest part is to filter attachment list. Use this code add_filter(‘ajax_query_attachments_args’, function($args) { $args[‘meta_query’] = array( array( ‘key’ => ‘my_image_meta’, ‘value’ => $some_value, ‘compare’ => ‘=’ ) ); return $args; }); However this code will filter all media library queries. You may want to pass some additional parameter from wp.media. This answer may be helpful.

Add/change multipart_params parameter when uploading post image

To send a customer data to the server, do the following customFileFrame.uploader.options.uploader.params.yourCustomProperty = ‘yourCustomValue’; Where: yourCustomProperty – parameter name yourCustomValue – parameter value processing data from the server add_action(‘add_attachment’, array($this, ‘addAttachmentParama’)); public function addAttachmentParama($post_id){ if (isset($_REQUEST[‘yourCustomProperty’]) && isset($_REQUEST[‘action’]) && ‘upload-attachment’ == $_REQUEST[‘action’]) { update_post_meta($post_id, ‘yourCustomProperty’, $_REQUEST[‘yourCustomProperty’]); } } Mini Plugin for example <?php /* Plugin … Read more

Image size filtering in Media uploader according to custom post type

Add following code in your themes functions.php file function theme_set_default_image_size() { global $post_type; $custom_image_size=”medium”; if($post_type == ‘news’) $custom_image_size=”news_image_size”; else if($post_type == ‘product’) $custom_image_size=”product_image_size”; else if($post_type == ‘service’) $custom_image_size=”service_image_size”; return $custom_image_size; } add_filter( ‘pre_option_image_default_size’, ‘theme_set_default_image_size’ );

Why are two functions over-riding each other?

It looks like you are overwriting the comment text with your commentimage_comment_text2 filter, try this to append the ratings text: add_filter( ‘comment_text’, ‘commentimage_comment_text2′ ); function commentimage_comment_text2( $comment ){ $rtt = “<br>Rating”; return $comment.$rtt; } ps: you forgot the $comment input parameter. Here is a poor man’s skematic picture of the filter flow in WordPress 😉 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)