BPMediaImporter::file_array PHP Method

file_array() static public method

static public file_array ( $filepath )
    static function file_array($filepath)
    {
        $path_info = pathinfo($filepath);
        $filetype = wp_check_filetype($filepath);
        $file['error'] = '';
        $file['name'] = $path_info['basename'];
        $file['type'] = $filetype['type'];
        $file['tmp_name'] = $filepath;
        $file['size'] = filesize($filepath);
        return $file;
    }

Usage Example

Beispiel #1
0
 static function make_copy($filepath)
 {
     $upload_dir = wp_upload_dir();
     $path_info = pathinfo($filepath);
     $tmp_dir = trailingslashit($upload_dir['basedir']) . 'bp-album-importer';
     $newpath = trailingslashit($tmp_dir) . $path_info['basename'];
     if (!is_dir($tmp_dir)) {
         wp_mkdir_p($tmp_dir);
     }
     if (file_exists($filepath)) {
         if (copy($filepath, $newpath)) {
             return BPMediaImporter::file_array($newpath);
         }
     }
     return 0;
 }