Code Duplication    Length = 34-34 lines in 2 locations

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

@@ 593-626 (lines=34) @@
590
			$response['exif']   = $metadata;
591
		}
592
593
		if ( in_array( $ext, array( 'ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v' ) ) ) {
594
			$metadata = wp_get_attachment_metadata( $media_item->ID );
595
			if ( isset( $metadata['height'], $metadata['width'] ) ) {
596
				$response['height'] = $metadata['height'];
597
				$response['width']  = $metadata['width'];
598
			}
599
600
			if ( isset( $metadata['length'] ) ) {
601
				$response['length'] = $metadata['length'];
602
			}
603
604
			// add VideoPress info
605
			if ( function_exists( 'video_get_info_by_blogpostid' ) ) {
606
				$info = video_get_info_by_blogpostid( $this->site->blog_id, $media_id );
607
608
				// Thumbnails
609
				if ( function_exists( 'video_format_done' ) && function_exists( 'video_image_url_by_guid' ) ) {
610
					$response['thumbnails'] = array( 'fmt_hd' => '', 'fmt_dvd' => '', 'fmt_std' => '' );
611
					foreach ( $response['thumbnails'] as $size => $thumbnail_url ) {
612
						if ( video_format_done( $info, $size ) ) {
613
							$response['thumbnails'][ $size ] = video_image_url_by_guid( $info->guid, $size );
614
						} else {
615
							unset( $response['thumbnails'][ $size ] );
616
						}
617
					}
618
				}
619
620
				$response['videopress_guid'] = $info->guid;
621
				$response['videopress_processing_done'] = true;
622
				if ( '0000-00-00 00:00:00' == $info->finish_date_gmt ) {
623
					$response['videopress_processing_done'] = false;
624
				}
625
			}
626
		}
627
628
		$response['thumbnails'] = (object) $response['thumbnails'];
629

class.json-api-endpoints.php 1 location

@@ 1215-1248 (lines=34) @@
1212
			$response['exif']   = $metadata;
1213
		}
1214
1215
		if ( in_array( $ext, array( 'ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v' ) ) ) {
1216
			$metadata = wp_get_attachment_metadata( $media_item->ID );
1217
			if ( isset( $metadata['height'], $metadata['width'] ) ) {
1218
				$response['height'] = $metadata['height'];
1219
				$response['width']  = $metadata['width'];
1220
			}
1221
1222
			if ( isset( $metadata['length'] ) ) {
1223
				$response['length'] = $metadata['length'];
1224
			}
1225
1226
			// add VideoPress info
1227
			if ( function_exists( 'video_get_info_by_blogpostid' ) ) {
1228
				$info = video_get_info_by_blogpostid( $this->api->get_blog_id_for_output(), $media_id );
1229
1230
				// Thumbnails
1231
				if ( function_exists( 'video_format_done' ) && function_exists( 'video_image_url_by_guid' ) ) {
1232
					$response['thumbnails'] = array( 'fmt_hd' => '', 'fmt_dvd' => '', 'fmt_std' => '' );
1233
					foreach ( $response['thumbnails'] as $size => $thumbnail_url ) {
1234
						if ( video_format_done( $info, $size ) ) {
1235
							$response['thumbnails'][ $size ] = video_image_url_by_guid( $info->guid, $size );
1236
						} else {
1237
							unset( $response['thumbnails'][ $size ] );
1238
						}
1239
					}
1240
				}
1241
1242
				$response['videopress_guid'] = $info->guid;
1243
				$response['videopress_processing_done'] = true;
1244
				if ( '0000-00-00 00:00:00' == $info->finish_date_gmt ) {
1245
					$response['videopress_processing_done'] = false;
1246
				}
1247
			}
1248
		}
1249
1250
		$response['thumbnails'] = (object) $response['thumbnails'];
1251