You appear to be a bot. Output may be restricted
Description
Save the contents of the media file block as an actual media fileIf sent the media array is expected to consist of:
- url – the attachment URL – probably ignored
- name – the file name ( e.g. oik-clone-v0.6.zip )
- type – the type of the file ( e.g. application/zip )
- md5 – the MD5 calculated hash of the file
- data – the base64 encoded file contents
Usage
$array = oik_clone_save_media_file( $time, $post );
Parameters
- $time
- ( string ) required – the original post date. It's used to put the attachment in the correct folder
- $post
- ( mixed ) optional –
Returns
array the file array defining the temporary file created from the media or nullSource
File name: oik-clone/admin/oik-clone-media.phpLines:
1 to 30 of 30
function oik_clone_save_media_file( $time, $post=null ) { $media_file = null; $jmedia = bw_array_get( $_REQUEST, "media", null ); if ( $jmedia ) { $jmedia = stripslashes( $jmedia ); $media = json_decode( $jmedia, true ); if ( $media ) { bw_trace2( $media, "media" ); $url = bw_array_get( $media, "url", null ); $name = bw_array_get( $media, "name", null ); $type = bw_array_get( $media, "type", null ); $data = bw_array_get( $media, "data", null ); $md5 = bw_array_get( $media, "md5", null ); $contents = oik_clone_validate_media_fields( $data, $md5 ); if ( $contents ) { $tmp_file = oik_clone_write_tmp_file( $name, $contents ); if ( $tmp_file ) { $media_file = oik_clone_write_media_file( $name, $type, $tmp_file, $time ); } } } } else { $media_file = oik_clone_load_media_from_files( $time ); if ( null === $media_file ) { $media_file = oik_clone_pull_media_file( $time, $post ); } } bw_trace2( $media_file, "media_file", false ); return( $media_file ); }View on GitHub