Topic: Simpleviewer cannot find correct upload folder for WPMU / WP Network

Hi.

I've just installed Simpleviewer on WP 3.0.1 which is running multisite / network.
In multisite "mode" images are uplaoded into the /blog.dir/blodID/files/ folder.

The problem is that the SV is only using the /upload folder.

Can someone please update the plugin so it detects is its a single site blog og multisite?


You are welcome to use some of this code:

function define_constants() {
  $upload_dir = get_upload_dir();
  
  define('FB_BASE_DIR', $upload_dir['basedir']);
  define('FB_BASE_URL', $upload_dir['baseurl']);
  define('FB_MAX_FILE_SIZE', number_format( (get_site_option( 'fileupload_maxk', 1500 ))/1024));
  define('FB_PLUGIN_DIR', trailingslashit( str_replace("\\","/", WP_PLUGIN_DIR . '/' . plugin_basename( dirname(__FILE__) ) ) ) );
  define('FB_PLUGIN_URL', trailingslashit( str_replace("\\","/", WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) ) ) );
}

function get_upload_dir() {
    $siteurl = get_option( 'siteurl' );
    $upload_path = get_option( 'upload_path' );
    $upload_path = trim($upload_path);
    
    if ( empty($upload_path) ) {
        $dir = WP_CONTENT_DIR . '/uploads';
    } else {
        $dir = $upload_path;
        if ( 'wp-content/uploads' == $upload_path ) {
            $dir = WP_CONTENT_DIR . '/uploads';
        } elseif ( 0 !== strpos($dir, ABSPATH) ) {
            // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
            $dir = path_join( ABSPATH, $dir );
        }
    }

    if ( !$url = get_option( 'upload_url_path' ) ) {
        if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
            $url = WP_CONTENT_URL . '/uploads';
        else
            $url = trailingslashit( $siteurl ) . $upload_path;
    }

    if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
        $dir = ABSPATH . UPLOADS;
        $url = trailingslashit( $siteurl ) . UPLOADS;
    }

    if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
        if ( defined( 'BLOGUPLOADDIR' ) )
            $dir = untrailingslashit(BLOGUPLOADDIR);
        $url = str_replace( UPLOADS, 'files', $url );
    }
  
  if (!is_dir($dir)) {
    mkdir($dir, 0700);
  } 

  $uploads = apply_filters( 'upload_dir', array( 'basedir' => $dir, 'baseurl' => $url) );      
  
  return $uploads; 
}

Re: Simpleviewer cannot find correct upload folder for WPMU / WP Network

*bump*