• Resolved vralle

    (@vit-1)


    Hi! Many thanks to author of AFS for plugin. The plugin works fine, but after the update have questions.

    I have:
    WP Multisite and media folder outside WP root directory
    D:\site – site root
    D:\site\wordpress\ – wp dir
    D:\site\media\ – wp upload dir

    WP Upload settings
    upload_url: http://media.site.com
    upload_path: D:\site\media\

    AFS Root Directory: d:\site\media\
    relative path, like “../media/”, don’t valid?

    add file with v3.2.x D:\site\media\example\example.jpg and return valid url http://media.site.com/example/example.jpg

    after update to v.3.3 AFS return wrong url http://media.site.com/D:/site/media/example/example.jpg

    Any hint to fix url?

    https://wordpress.org/plugins/add-from-server/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dion Hulse

    (@dd32)

    Meta Developer

    Relative urls/paths are not supported. Use absolute paths.

    Sounds like a incompatibility with Windows systems. Good luck finding a solution, I’ll check into it in the next couple of weeks.

    Thread Starter vralle

    (@vit-1)

    Yep, local server and W10x64
    I look on my online server (Debian) now.
    WP dir: /usr/www/site/wp
    WP media dir: /usr/www/site/media

    add file /usr/www/site/media/example/pack_p.jpg"
    and return wrong url http://media.site.com/_site_com/example/pack_p.jpg

    Thread Starter vralle

    (@vit-1)

    update

    Thread Starter vralle

    (@vit-1)

    class.add-from-server.php, line 377:
    replace
    $new_file = str_replace( wp_normalize_path( $uploads['basedir'] ), $uploads['basedir'], $new_file );

    with old fix
    $new_file = str_replace( strtolower(str_replace('\\', '/', $uploads['basedir'])), $uploads['basedir'], $new_file);

    W10x64 – work!)

    Plugin Author Dion Hulse

    (@dd32)

    Meta Developer

    @vitaliy Ah my apologies, I’ve now spotted the issue.

    You need to ensure that the capitalisation of the path in settings matches what the webserver see’s. What this means, is you need to capitalise the Drive letter – ie. you’ve got d:\site\media\ but need to use D:\site\media\. That’ll happen automatically in WordPress 4.4+, but since that’s not yet released, you’ll need to handle it manually.

    Thread Starter vralle

    (@vit-1)

    WP4.4b1 – not work.
    AFS generate “http://media.site.com/D:/web/site.com/media/example/example_sizexsize.jpg”

    wp_insert_attachment – work fine for guid: “http://media.site.com/example/example.jpg”
    but wrong meta_key -> _wp_attached_file: full path “D:/web/site.com/media/example/example.jpg”
    instead “example/example.jpg”

    and too wrong path for _wp_attachment_metadata

    Thread Starter vralle

    (@vit-1)

    Yep!

    function handle_import_file:

    line $new_file = str_replace( wp_normalize_path( $uploads['basedir'] ), $uploads['basedir'], $new_file );

    @param $new_file: D:/WEB/site.com/storage/file.jpg
    @param wp_normalize_path( $uploads[‘basedir’] ): D:/web/site.com/storage
    @param $uploads[‘basedir’]: D:\web\hw-lab.com\storage
    @return $new_file: D:/WEB/site.com/storage/file.jpg

    The problem with capital letters in the path

    Thread Starter vralle

    (@vit-1)

    and may be fix:
    $new_file = preg_replace( '/' . preg_quote( wp_normalize_path( $uploads['basedir'] ), '/' ) . '/i', $uploads['basedir'], $new_file );

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘AFS v3.3.x and media path’ is closed to new replies.