WordPress.org

Ready to get started?Download WordPress

Forums

New Nine Adaptive Images
NGINX rules for Adaptive Images? (7 posts)

  1. callmeforsox
    Member
    Posted 6 months ago #

    Does anyone know the rule to use for NGINX servers for adaptive images?

    Searched Google, found this:

    if ($request_filename !~* ai-cache) { rewrite \.(?:jpe?g|gif|png)$ /adaptive-images.php last; }

    Don't think it's working though.

    http://wordpress.org/plugins/new-nine-adaptive-images/

  2. Dave Naylor
    Member
    Posted 6 months ago #

    This is working for me:

    location / {
        try_files $uri $uri/ /index.php?$args;
        if ($request_uri ~ "wp-content/uploads"){
            rewrite \.(?:jpe?g|gif|png)$ /wp-content/plugins/new-nine-adaptive-images/adaptive-images.php last;
        }
    }

    You may have to manually create wp-content/uploads/ai-cache/ and give it appropriate write permissions.

  3. callmeforsox
    Member
    Posted 6 months ago #

    Been testing this rule but doesn't seem to be working. Checking the site from a phone, the only directory that's ever created is for the 1200 breakpoint. And even then, I've only gotten two images to be created.

  4. Dave Naylor
    Member
    Posted 6 months ago #

    If you're seeing adaptive images, the rule is working. It's the plugin that deals with different breakpoints. I added several and it resulted in the appropriate creation of the relevant directories.

  5. callmeforsox
    Member
    Posted 5 months ago #

    Definitely not working. Not sure how those two images were even created but no other images have been created since.

  6. Dave Naylor
    Member
    Posted 5 months ago #

    That's a pity it doesn't work for you. I just tested my install again with this image:

    identify Aerial04.jpg
    Aerial04.jpg JPEG 3200x2000 3200x2000+0+0 8-bit sRGB 4.189MB 0.000u 0:00.000

    Once uploaded to my WordPress site and viewed on my 1920 width monitor:

    identify ai-cache/1900/wp-content/uploads/2014/01/Aerial04.jpg
    ai-cache/1900/wp-content/uploads/2014/01/Aerial04.jpg JPEG 1900x1188 1900x1188+0+0 8-bit DirectClass 446KB 0.020u 0:00.030

    Then on my Nexus 4:

    identify ai-cache/768/wp-content/uploads/2014/01/Aerial04.jpg
    ai-cache/768/wp-content/uploads/2014/01/Aerial04.jpg JPEG 768x480 768x480+0+0 8-bit DirectClass 82.9KB 0.000u 0:00.009

    So as you can see. Definitely working.

  7. Dave Naylor
    Member
    Posted 5 months ago #

    As a follow up, I was tweaking my nginx vhost conf today and added this:

    # Aggressive caching for static files
    location ~* \.(asf|asx|wax|... big list of extensions)$ {
            expires 31536000s;
            access_log off;
            log_not_found off;
            add_header Pragma public;
            add_header Cache-Control "max-age=31536000, public";
    }

    It stopped adaptive images working. I've taken it back out for now and adaptive images work again.

Reply

You must log in to post.

About this Plugin

About this Topic