WordPress.org

Ready to get started?Download WordPress

Forums

WP Retina 2x
[resolved] Multisite html rewrite only works when debug is enabled (6 posts)

  1. hulsman1986
    Member
    Posted 1 year ago #

    Hello! I am have been fiddling with your plugin, it is awesome. However, when trying to use the wp retina 2x plugin within a multisite; trouble starts to appear. Hopefully there is someone who has encountered the following issue and has found a solution.

    First of; client side isnt an option as it doesn't allow my images to be responsive. So i tried the server side option, but without succes. Tried to update the retinaimages.php, added the rewrite rule, but no luck. So i finally chose the html rewrite.

    Html rewrite works! BUT only when debug mode is enabled. The same goes for the client side option. It works, but only in debug mode.

    This is happening on local, on a staging server ánd on our live server. So i don't think its a Cloudflare thing. Does anyone recognize this issue?

    http://wordpress.org/extend/plugins/wp-retina-2x/

  2. hulsman1986
    Member
    Posted 1 year ago #

    I opted for the client side solution (for now) and moderated the retina.js in order to keep the images at 100% width and auto height.

    $('#main-games img').each(function(){
            new RetinaImage(this);
    });

    Only issue that remains is that @2x is added to the image url when using this snippet, even though @2x is already added... So you get the correct images but also a load of 404's in the console :D

  3. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    Html rewrite works! BUT only when debug mode is enabled

    Are you using caching? Maybe a cache plugin?

    Cloudflare thing

    I don't know on your local, but with Cloudflare the server-side wouldn't work. The HTML Rewrite would though, and the Client-side too.

    Only issue that remains is that @2x is added to the image url when using this snippet, even though @2x is already added

    Why is @2x already there?
    You can check if the filename contains @2x, and if it doesn't, then you'll call the line "new RetinaImage", otherwise not. Simple :)

  4. hulsman1986
    Member
    Posted 1 year ago #

    Hi, thanks for replying! Still lovin' you plugin and spreading the name towards my m8's :)

    I am sticking with the client side solution. The site is cached three times through memcache, varnish and cloudflare... I bet one of those might cause the rewrite to go bad? :P

    Anyway, the issue with the double @2x was due to a lazy load script. it caused the retina.js plugin to be called again when loading new content :D i sawk.

    My dirty solution was to add the following script when loading new content:

    //serve retina images. Works with the WP 2x retina plugin
    $('#main-games .article-header img').each(function(){
          var imageSource = $(this).attr('src');
          if (imageSource.indexOf("@2x") >= 0) {
                //already is a retina image
          } else {
                //its not a retina image
                 new RetinaImage(this);
          }
    });
  5. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    memcache, varnish and cloudflare

    Memcache => No HTML Rewrite, Cloudflare => No Server-Side. Only Client-Side left ^^

    the issue with the double @2x was due to a lazy load script

    Ah yes, that's often the case, and that's where the Server-Side works very well in fact.

    My dirty solution was to add the following script when loading new content

    Your solution is not dirty: it's the right one :)

  6. hulsman1986
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic