Changeset 805652
- Timestamp:
- 11/17/2013 06:05:13 AM (12 years ago)
- File:
-
- 1 edited
-
photostream-sync/trunk/photostream-sync.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
photostream-sync/trunk/photostream-sync.php
r661759 r805652 3 3 /* 4 4 Plugin Name: photostream-sync 5 Description: Synchronize your public iCloud photostreams to your WordPress installation. Import images, create gellery posts, and more.5 Description: Synchronize your public iCloud photostreams to your WordPress installation. Import images, Import videos, create gellery posts, and more. 6 6 Author: Demitrious Kelly <apokalyptik@apokalyptik.com> 7 Version: 1.0.37 Version: 2.0.0 8 8 Author URI: http://blog.apokalyptik.com/ 9 9 */ … … 240 240 name="photostream[edit][<?php esc_attr_e( $key );?>][rename_file]" 241 241 value="<?php esc_attr_e( $stream->rename_file ); ?>" 242 placeholder="stream->title - owner->fullName -- image->date(Y-m-d).jpg"/>242 placeholder="stream->title - owner->fullName -- file->date(Y-m-d).jpg"/> 243 243 <br/> 244 244 <?php $this->display_text_transform_options(); ?> … … 342 342 name="photostream[add][rename_file]" 343 343 value="<?php esc_attr_e( $stream->rename_file ); ?>" 344 placeholder="stream->title - owner->fullName -- image->date(Y-m-d).jpg"/>344 placeholder="stream->title - owner->fullName -- file->date(Y-m-d).jpg"/> 345 345 <br/> 346 346 <?php $this->display_text_transform_options(); ?> … … 477 477 if ( !$processed ) 478 478 $ready = false; 479 if ( $processed['type'] == 'video/mp4' ) { 480 $group_post['post_content'] = $group_post['post_content'] . sprintf( '[video mp4="%s"]', $processed['url'] ); 481 wp_update_post($group_post); 482 } 479 483 } 480 484 if ( !$ready ) … … 510 514 $path = $this->apply_image_centric_text_transforms( $path, $image ); 511 515 $path = $this->apply_generic_text_transforms( $path ); 516 $path = preg_replace( '/\.(jpe?g|mp4)$/i', '', $path ); 517 if ( isset( $image->mediaAssetType ) && $image->mediaAssetType == 'video' ) 518 $path = "$path.mp4"; 519 else 520 $path = "$path.jpg"; 512 521 if ( empty( $path ) ) 513 522 return false; … … 515 524 if ( empty( $mime ) || empty( $mime['type'] ) ) 516 525 return false; 517 foreach( $derivatives[$width]->_wp_ps_url as $url ) { 518 $bits = wp_remote_retrieve_body( $response = wp_remote_get( $url ) ); 519 if ( $bits ) 520 break; 526 if ( isset( $image->mediaAssetType ) && $image->mediaAssetType == 'video' ) { 527 foreach( array( '720p', '360p' ) as $resolution ) { 528 foreach( $derivatives[$resolution]->_wp_ps_url as $url ) { 529 $bits = wp_remote_retrieve_body( $response = wp_remote_get( $url ) ); 530 if ( $bits ) 531 break; 532 } 533 if ( $bits ) 534 break; 535 } 536 } else { 537 foreach( $derivatives[$width]->_wp_ps_url as $url ) { 538 $bits = wp_remote_retrieve_body( $response = wp_remote_get( $url ) ); 539 if ( $bits ) 540 break; 541 } 521 542 } 522 543 if ( empty( $bits ) ) … … 535 556 'guid' => $upload[ 'url' ] 536 557 ); 537 if ( function_exists( 'exif_read_data' ) ) { 538 $exif = exif_read_data( $upload[ 'file' ] ); 539 } else { 540 $exif = false; 558 559 $exif = false; 560 if ( !isset( $image->mediaAssetType ) || $image->mediaAssetType != 'video' ) { 561 if ( function_exists( 'exif_read_data' ) ) 562 $exif = exif_read_data( $upload[ 'file' ] ); 541 563 } 542 564 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); … … 553 575 $struct = array( 554 576 'id' => strval( $id ), 555 'file' => $ name,577 'file' => $upload['file'], 556 578 'url' => $upload[ 'url' ], 557 'type' => $ type579 'type' => $mime['type'] 558 580 ); 559 581 $stream->processed_groups[$group_key][$image->photoGuid] = time(); … … 629 651 630 652 // Image Replacements 631 $text = str_replace( 'image->caption', $image->caption, $text ); 632 $text = str_replace( 'image->guid', $image->photoGuid, $text ); 633 if ( preg_match_all( '/image->date\(([^)]+)\)/', $text, $matches ) ) { 653 $text = str_replace( 'image->', 'file->', $text ); // Maintain backwards compatibility 654 $text = str_replace( 'video->', 'file->', $text ); // Just in case someone tries this... 655 $text = str_replace( 'file->caption', $image->caption, $text ); 656 $text = str_replace( 'file->guid', $image->photoGuid, $text ); 657 if ( preg_match_all( '/file->date\(([^)]+)\)/', $text, $matches ) ) { 634 658 $datetime = strtotime( $image->dateCreated ); 635 659 foreach( array_keys( $matches[0] ) as $m )
Note: See TracChangeset
for help on using the changeset viewer.