Skip to content

Instantly share code, notes, and snippets.

@BhargavBhandari90
Last active April 19, 2017 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BhargavBhandari90/f0d09a644fb243dbf604fc7b965a7c36 to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/f0d09a644fb243dbf604fc7b965a7c36 to your computer and use it in GitHub Desktop.
This will skip videos for uploading to s3 bucket
<?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