• Ryan

    (@rrhode)


    Hi there,

    This plugin doesn’t work with the WP upload filters including:
    wp_handle_upload_prefilter
    wp_handle_upload

    I have noticed it does use wp_upload_dir which also has a filter inside it but I’m not sure how to make that do what I want. What I want to do is redirect videos to /uploads/videos rather than a date folder because it is linked to a remote server for encoding videos and uploading to Amazon S3/CloudFront for serving them.

    Another issue I noticed was that it doesn’t display the plugin buttons in the Media Library itself for some reason, only when adding media from a post. Is there a reason for this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author minnur

    (@minnur)

    Thank you for your feedback, I will look into this when I have more capacity. One of the reasons why buttons not appearing in the Media Library itself is that the WP itself doesn’t use the same filter on the page and there was no alternative filter available, possibly this is a WordPress bug. I need more time to do the research.

    Thread Starter Ryan

    (@rrhode)

    Thanks for the response! The main issue is the upload filters not working on the file output.

    Perhaps you could add a filter in above the file_put_contents line in the save_remote_file function of external-media\classes\WP_ExternalPluginBase.php

    $file_path = apply_filters( 'external_media_file_path', $file_path );

    That way I can filter it myself and adjust it like so:

    add_filter( 'external_media_file_path', 'external_media_file_path' );
    function external_media_file_path( $file ) {
    	$parts     = pathinfo( $file );
    	$extension = strtoupper( $parts['extension'] );
    
    	$formats = array(
    		"3G2",
    		"3GP",
    		"ASF",
    		"ASX",
    		"AVI",
    		"FLV",
    		"M4V",
    		"MOV",
    		"MP4",
    		"MPG",
    		"RM",
    		"VOB",
    		"WEBM",
    		"WMV"
    	);
    
    	if ( ! in_array( $extension, $formats ) ) {
    		return $file;
    	}
    
    	$upload_dir = wp_upload_dir();
    	$file       = str_replace( $upload_dir['subdir'], '/videos', $parts['dirname'] ) . '/' . $parts['basename'];
    
    	return $file;
    }
    
    • This reply was modified 9 years ago by Ryan.
    Plugin Author minnur

    (@minnur)

    @rrhode thanks for this. I will make sure to include this filter in the next release.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Doesn’t fire upload filters’ is closed to new replies.