• Resolved Alessio

    (@sparkis70)


    Hi, thanks for the plugin, I use it on all my sites and usually have no issues.

    I activated it on a multisite network and it doesn’t seem to work though.
    The webp files are generated, but the original png is still used in the front:

    image-1
    image-2


    Don’t know if its a server issue or plugin issue.

    Thanks in advance!

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

    (@mateuszgbiorczyk)

    Hi @sparkis70,

    Thank you for your message.

    The reports we receive very often do not concern a problem with the plugin operation, but problems with understanding how the plugin works. Below I have attached the tutorial describing how to test the plugin:
    https://mattplugins.com/docs/how-to-test-converter-for-media-plugin

    To be able to look at your website, I need its URL.

    Best,
    Mateusz

    I can concur that when you network-enable the plugin on a WP multisite, it finds and converts the images on every single blog, but it doesn’t set the htaccess rules. I note in the Expert Settings section there are

    • htaccess_rewrite_root
    • htaccess_rewrite_path
    • htaccess_rewrite_parent
    • htaccess_rewrite_output
    • htaccess_rewrite_flag_redirect

    but couldn’t find any explanation on how to use them. Maybe there’s a link somewhere, but I must have missed it.

    So I came up with these htaccess rules for multisite:

    RewriteEngine On
    # ————————————————————
    # 1. UPLOADS directory (any subdirectory under wp-content/uploads/)
    # ————————————————————

    # AVIF redirect
    RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.+).(jpe?g|png)$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/uploads/%1.%2.avif -f
    RewriteRule .* /wp-content/uploads-webpc/uploads/%1.%2.avif [R=302,NC,L]

    # WebP redirect (if AVIF missing)
    RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.+).(jpe?g|png)$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/uploads/%1.%2.webp -f
    RewriteRule .* /wp-content/uploads-webpc/uploads/%1.%2.webp [R=302,NC,L]

    # If neither AVIF nor WebP exists, serve the original file directly
    RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.+).(jpe?g|png)$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} -f
    RewriteRule .* – [L]

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @thejasonator This is what the rules added to the .htaccess file in the /wp-content/ directory should look like:

    # BEGIN Converter for Media
    # ! --- DO NOT EDIT PREVIOUS LINE --- !
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteOptions Inherit
    
      RewriteCond %{QUERY_STRING} original$
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule . - [L]
    
      RewriteCond %{HTTP_ACCEPT} image/avif
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpg.avif -f
      RewriteRule (.+)\.jpg$ /wp-content/uploads-webpc/$1.jpg.avif [NC,T=image/avif,L]
      RewriteCond %{HTTP_ACCEPT} image/avif
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpeg.avif -f
      RewriteRule (.+)\.jpeg$ /wp-content/uploads-webpc/$1.jpeg.avif [NC,T=image/avif,L]
      RewriteCond %{HTTP_ACCEPT} image/avif
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.png.avif -f
      RewriteRule (.+)\.png$ /wp-content/uploads-webpc/$1.png.avif [NC,T=image/avif,L]
      RewriteCond %{HTTP_ACCEPT} image/avif
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.webp.avif -f
      RewriteRule (.+)\.webp$ /wp-content/uploads-webpc/$1.webp.avif [NC,T=image/avif,L]
    
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpg.webp -f
      RewriteRule (.+)\.jpg$ /wp-content/uploads-webpc/$1.jpg.webp [NC,T=image/webp,L]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpeg.webp -f
      RewriteRule (.+)\.jpeg$ /wp-content/uploads-webpc/$1.jpeg.webp [NC,T=image/webp,L]
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.png.webp -f
      RewriteRule (.+)\.png$ /wp-content/uploads-webpc/$1.png.webp [NC,T=image/webp,L]
    </IfModule>
    <IfModule mod_headers.c>
      <FilesMatch "(?i)\.(jpg|png|webp|jpeg)(\.(webp|avif))?$">
        Header always set Cache-Control "private"
        Header always set X-LiteSpeed-Cache-Control "no-cache"
        Header append Vary "Accept"
      </FilesMatch>
    </IfModule>
    # ! --- DO NOT EDIT NEXT LINE --- !
    # END Converter for Media
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.