Code Duplication    Length = 34-38 lines in 2 locations

sal/class.json-api-post-base.php 1 location

@@ 621-654 (lines=34) @@
618
			$response['exif']   = $metadata;
619
		}
620
621
		if ( in_array( $ext, array( 'ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v' ) ) ) {
622
			$metadata = wp_get_attachment_metadata( $media_item->ID );
623
			if ( isset( $metadata['height'], $metadata['width'] ) ) {
624
				$response['height'] = $metadata['height'];
625
				$response['width']  = $metadata['width'];
626
			}
627
628
			if ( isset( $metadata['length'] ) ) {
629
				$response['length'] = $metadata['length'];
630
			}
631
632
			// add VideoPress info
633
			if ( function_exists( 'video_get_info_by_blogpostid' ) ) {
634
				$info = video_get_info_by_blogpostid( $this->site->get_id(), $media_id );
635
636
				// Thumbnails
637
				if ( function_exists( 'video_format_done' ) && function_exists( 'video_image_url_by_guid' ) ) {
638
					$response['thumbnails'] = array( 'fmt_hd' => '', 'fmt_dvd' => '', 'fmt_std' => '' );
639
					foreach ( $response['thumbnails'] as $size => $thumbnail_url ) {
640
						if ( video_format_done( $info, $size ) ) {
641
							$response['thumbnails'][ $size ] = video_image_url_by_guid( $info->guid, $size );
642
						} else {
643
							unset( $response['thumbnails'][ $size ] );
644
						}
645
					}
646
				}
647
648
				$response['videopress_guid'] = $info->guid;
649
				$response['videopress_processing_done'] = true;
650
				if ( '0000-00-00 00:00:00' == $info->finish_date_gmt ) {
651
					$response['videopress_processing_done'] = false;
652
				}
653
			}
654
		}
655
656
		$response['thumbnails'] = (object) $response['thumbnails'];
657

class.json-api-endpoints.php 1 location

@@ 1268-1305 (lines=38) @@
1265
			$response['exif']   = $metadata;
1266
		}
1267
1268
		if (
1269
		        in_array( $ext, array( 'ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v' ) )
1270
            ||
1271
                $response['mime_type'] === 'video/videopress'
1272
        ) {
1273
			$metadata = wp_get_attachment_metadata( $media_item->ID );
1274
			if ( isset( $metadata['height'], $metadata['width'] ) ) {
1275
				$response['height'] = $metadata['height'];
1276
				$response['width']  = $metadata['width'];
1277
			}
1278
1279
			if ( isset( $metadata['length'] ) ) {
1280
				$response['length'] = $metadata['length'];
1281
			}
1282
1283
			// add VideoPress info
1284
			if ( function_exists( 'video_get_info_by_blogpostid' ) ) {
1285
				$info = video_get_info_by_blogpostid( $this->api->get_blog_id_for_output(), $media_id );
1286
1287
				// Thumbnails
1288
				if ( function_exists( 'video_format_done' ) && function_exists( 'video_image_url_by_guid' ) ) {
1289
					$response['thumbnails'] = array( 'fmt_hd' => '', 'fmt_dvd' => '', 'fmt_std' => '' );
1290
					foreach ( $response['thumbnails'] as $size => $thumbnail_url ) {
1291
						if ( video_format_done( $info, $size ) ) {
1292
							$response['thumbnails'][ $size ] = video_image_url_by_guid( $info->guid, $size );
1293
						} else {
1294
							unset( $response['thumbnails'][ $size ] );
1295
						}
1296
					}
1297
				}
1298
1299
				$response['videopress_guid'] = $info->guid;
1300
				$response['videopress_processing_done'] = true;
1301
				if ( '0000-00-00 00:00:00' == $info->finish_date_gmt ) {
1302
					$response['videopress_processing_done'] = false;
1303
				}
1304
			}
1305
		}
1306
1307
		$response['thumbnails'] = (object) $response['thumbnails'];
1308