Last active
April 19, 2017 14:02
-
-
Save BhargavBhandari90/f0d09a644fb243dbf604fc7b965a7c36 to your computer and use it in GitHub Desktop.
This will skip videos for uploading to s3 bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* rtamazon_can_upload_to_bucket Prevent preticular media type to upload to s3 bucket | |
* @param bool $status status of filter | |
* @param int $attachment_id Id of uploading media | |
* @return bool Return false if media type is video | |
*/ | |
function rtamazon_can_upload_to_bucket( $status, $attachment_id ) { | |
// Get the mime type for uploading video. | |
$mime_type = get_post_mime_type( $attachment_id ); | |
$type_arr = explode( '/' , $mime_type ); | |
// Get media type. | |
$type = $type_arr[0]; | |
// Check if it is video type, then skip uploading to bucket. | |
// Other types you can define i.e 'image', 'audio' etc. | |
if ( ! empty( $type ) && 'video' === $type ) { | |
$status = false; | |
} | |
return $status; | |
} | |
add_filter( 'rtawss3_can_upload_to_bucket', 'rtamazon_can_upload_to_bucket', 99, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment