max-kk
8/22/2016 - 9:04 AM

Add first photo data to upload response array (in wp-foto-vote\public\class-fv-public-ajax.php)

Add first photo data to upload response array (in wp-foto-vote\public\class-fv-public-ajax.php)

FvLib.addHook('fv/upload/ready', function(data){
  // data.inserted_photo_datas[0].url   - Photo full url
});
<?php

add_filter('fv/public/upload/response', 'fv_upload_add_photo_data', 11, 1);

function fv_upload_add_photo_data($response) {
    if ( !empty($response['inserted_photo_ids'][0]) ) {
        $photo0 = ModelCompetitors::query()->findByPK( $response['inserted_photo_ids'][0] );
        if ( !empty($photo0) ) {
            $response['inserted_photo_datas'][0] = FV_Public::_prepare_contestant_to_js($photo0);
        }        
    }    
    
    return $response;
}