Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions includes/admin/services/class-rop-twitter-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,13 @@ private function twitter_media_post( $post_details, $api ) {
}

$upload_args = array(
'media' => $media_path,
'media_type' => $post_details['mimetype']['type'],
'media' => $media_path,
'media_type' => $post_details['mimetype']['type'],
'media_category' => 'tweet_image',
);

$options['chunkedUpload'] = false;

if ( ! empty( $photon_bypass ) && class_exists( 'Jetpack_Photon' ) ) {
// Re-enable Jetpack Photon filter.
add_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
Expand All @@ -511,19 +514,20 @@ private function twitter_media_post( $post_details, $api ) {
$upload_args['media_type'] = $post_details['mimetype']['type'];
$upload_args['media_category'] = 'tweet_video';
$status_check = true;
$options['chunkedUpload'] = true;
}

// Overwrite media_type and category if is Gif Post
if ( strpos( $post_details['mimetype']['type'], 'image/gif' ) !== false ) {
$upload_args['media_type'] = $post_details['mimetype']['type'];
$upload_args['media_category'] = 'tweet_gif';
$status_check = true;
$options['chunkedUpload'] = true;
}

$this->logger->info( 'Before upload to twitter . ' . json_encode( $upload_args ) );
$api->setTimeouts( 10, 60 );
$api->setApiVersion( '2' );
$options['chunkedUpload'] = true;
$media_response = $api->upload( 'media/upload', $upload_args, $options );

if ( isset( $media_response->data->id ) ) {
Expand Down
Loading