Skip to content

Commit c36fd53

Browse files
Update class-rop-twitter-service.php
1 parent 0b45a21 commit c36fd53

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

includes/admin/services/class-rop-twitter-service.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,14 @@ private function twitter_media_post( $post_details, $api ) {
495495
}
496496

497497
$upload_args = array(
498-
'media' => $media_path,
499-
'media_type' => $post_details['mimetype']['type'],
498+
'media' => $media_path,
499+
'media_type' => $post_details['mimetype']['type'],
500+
'media_category' => 'tweet_image',
500501
);
501502

503+
504+
$options['chunkedUpload'] = false;
505+
502506
if ( ! empty( $photon_bypass ) && class_exists( 'Jetpack_Photon' ) ) {
503507
// Re-enable Jetpack Photon filter.
504508
add_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
@@ -511,19 +515,20 @@ private function twitter_media_post( $post_details, $api ) {
511515
$upload_args['media_type'] = $post_details['mimetype']['type'];
512516
$upload_args['media_category'] = 'tweet_video';
513517
$status_check = true;
518+
$options['chunkedUpload'] = true;
514519
}
515520

516521
// Overwrite media_type and category if is Gif Post
517522
if ( strpos( $post_details['mimetype']['type'], 'image/gif' ) !== false ) {
518523
$upload_args['media_type'] = $post_details['mimetype']['type'];
519524
$upload_args['media_category'] = 'tweet_gif';
520525
$status_check = true;
526+
$options['chunkedUpload'] = true;
521527
}
522528

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

529534
if ( isset( $media_response->data->id ) ) {

0 commit comments

Comments
 (0)