• Resolved athleticcity

    (@athleticcity)


    Hello,
    1. I have a wp-multisite.
    2. my images are at /public/pict_test/uploads and not at public/wp-content/uploads.

    So I use and change this code:

    add_filter( 'webpc_site_root', function( $path ) {
        return ABSPATH;
    } );
    
    add_filter( 'webpc_dir_name', function( $path, $directory ) {
        if ( $directory !== 'uploads' ) {
            return $path;
        }
        return 'pict_test/uploads';
    }, 10, 2 );
    
    add_filter( 'webpc_dir_name', function( $path, $directory ) {
        if ( $directory !== 'webp' ) {
            return $path;
        }
        return 'pict_test/uploads-webpc';
    }, 10, 2 );
    
    add_filter( 'webpc_htaccess_rewrite_path', function( $prefix ) {
        return '/';
    } );
    

    The code adds this .htaccess to public/pict_test:

    # BEGIN WebP Converter
    # ! --- DO NOT EDIT PREVIOUS LINE --- !
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/pict_test/uploads-webpc/$1.jpg.webp -f
      RewriteRule (.+)\.jpg$ /pict_test/uploads-webpc/$1.jpg.webp [NC,T=image/webp,L]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/pict_test/uploads-webpc/$1.jpeg.webp -f
      RewriteRule (.+)\.jpeg$ /pict_test/uploads-webpc/$1.jpeg.webp [NC,T=image/webp,L]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{DOCUMENT_ROOT}/pict_test/uploads-webpc/$1.png.webp -f
      RewriteRule (.+)\.png$ /pict_test/uploads-webpc/$1.png.webp [NC,T=image/webp,L]
    </IfModule>
    <IfModule mod_headers.c>
      <FilesMatch "(?i)\.(jpg|jpeg|png)(\.(webp|avif))?$">
        Header always set Cache-Control "private"
        Header append Vary "Accept"
      </FilesMatch>
    </IfModule>
    # ! --- DO NOT EDIT NEXT LINE --- !
    # END WebP Converter
    

    The code adds the folder public/pict_test/uploads-webpc
    with this .htaccess:

    # BEGIN WebP Converter
    # ! --- DO NOT EDIT PREVIOUS LINE --- !
    <IfModule mod_mime.c>
      AddType image/webp .webp
    </IfModule>
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresByType image/webp "access plus 1 year"
    </IfModule>
    # ! --- DO NOT EDIT NEXT LINE --- !
    # END WebP Converter
    

    The problem is, the converted images are in this folder now:

    
    /public/pict_test/uploads/wp-content/uploads-webpc/.../users/.../apps/.../public/pict_test/uploads/sites/23/2022/04
    

    so,
    1. with the full path and
    2. not at public/pict_test/uploads-webpc, what I think is the right folder, or?

    What did I do wrong?
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hello @athleticcity,

    Thanks for your message.

    Can you show me configuration of your server (link to it can be found on the settings page of plugin in the section “We are waiting for your message”)?

    Please take a screenshot of the ENTIRE page and send it to me via e-mail: hello(at)mattplugins.com

    Best,
    Mateusz

    Thread Starter athleticcity

    (@athleticcity)

    I send you an email.
    Thanks

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @athleticcity I have received your message. From this it follows that your filters are added in the wrong way. They are not loaded. Where did you add them?

    Thread Starter athleticcity

    (@athleticcity)

    In the meantime I got it running. Because your plugin can only be activated in the network and not individually in the directories, I didn’t think of adding the filter to each individual directory. I only added the filter to the function.php at the server level and not in each individual directory. So I have to insert the filter in each individual directory. It works now. Thanks. 😉

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

The topic ‘Problem to get the right path’ is closed to new replies.