• Resolved greg

    (@gllorca)


    Dear all,

    I am using Nextgen gallery plugin on a multisite network.

    One of my custom plug-ins uses this code :

    // Forcing all sub-domains to use the same uploads folder
    if( !function_exists( 'no_uploads_subfolders' ) ){
    	function no_uploads_subfolders( $dirs ) {
    		$dirs['baseurl'] = network_site_url( '/wp-content/uploads' );
    		$dirs['basedir'] = ABSPATH . 'wp-content/uploads';
    		$dirs['path'] = $dirs['basedir'] . $dirs['subdir'];
    		$dirs['url'] = $dirs['baseurl'] . $dirs['subdir'];
    
    		return $dirs;
    	}
    }
    add_filter( 'upload_dir', 'no_uploads_subfolders' );

    However, when I upload an image in NextGen gallery, the resulting file is saved at /wp-content/uploads/site/2/nggallery instead of /wp-content/uploads/nggallery as I would like to.

    Could you please help me force this plugin to use the root folder, as I share images and galleries accross multiple sites ?

    Thank you very much !

    By the way : I am using it on a staging website and therefore won’t have any public URL to share, sorry.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Imagely

    (@imagely)

    @gllorca – This is all we can offer currently:

    add_filter('ngg_datamapper_table_name', 'something', 10, 2);
    function something( $table_name, $name ) {
      global $table_prefix;
      if ( strpos( $table_name, ‘ngg' ) !== FALSE ) {
        return $table_prefix . $name;
      }
    }

    The callback function is noted as “something” use whatever is most appropriate for your installation.

    The return value of $table_prefix . $name will return by default the main WordPress installation site, if you want to use a different sub-site then set the $table_prefix appropriately, for example, site 3 would use wp_3_ as the $table_prefix

    Also to note, all images should be uploaded to the specific site being used for all the other sub-sites.

    Thanks!

    – Cais.

    Thread Starter greg

    (@gllorca)

    Dear Cais,
    Thank you for your help.
    I don’t really understand how this code helps me solve the uploads folder issue.

    The table prefix is fine.

    The problem is the matter of the “specific site” sub-folder in the uploads/ directory. The plug-in is not supposed to use a “specific site” subfolder, it should upload pictures directly in wp-content/uploads/

    Plugin Contributor Imagely

    (@imagely)

    @gllorca – Perhaps I am not understanding what you are looking for and/or you are wanting to use something other than the following default: wp-content/uploads/sites/%BLOG_ID%/nggallery/ for your gallery paths?

    – Cais.

    Thread Starter greg

    (@gllorca)

    Dear Cais,
    Thank you for your answer.
    Yes, that is exactly that. I’d like to use wp-content/uploads/nggallery/ or directly wp-content/uploads/

    Plugin Contributor Imagely

    (@imagely)

    @gllorca – Did you change the default appropriately (although under a multisite I would not expect or recommend not including the site ID as part of the upload path)?

    Although, again, the code we suggested above is the best workaround we can suggest if you want to share all images across all sub-sites with NextGEN Gallery.

    Thanks!

    – Cais.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using the “UPLOAD_DIR” filter’ is closed to new replies.