WP Retina 2x
[resolved] Plugin is looking for @2x image at the relative path instead of absolute (7 posts)

  1. homebysix
    Posted 2 years ago #

    I have a WordPress site at http://www.pretendco.com, and another WordPress site at http://www.pretendco.com/widget.

    The images on both sites (and their @2x versions) are all stored at http://www.pretendco.com/static and referenced with an absolute path:
    <img src="/static/image1.png">

    The Retina 2X plugin works just fine on the main http://www.pretendco.com site, but doesn't work on the http://www.pretendco.com/widget site. The debug log reveals that the plugin is incorrectly looking for the images at /widget/static instead of /static.

    Other than putting the fully qualified domain name in the img src itself, is there a way to make Retina 2X look in the correct place for these images?


  2. homebysix
    Posted 1 year ago #

    I'm still having this problem, and would appreciate some assistance.

    It looks like absolute image paths are being served up relative to the WordPress "root" rather than truly absolute to the website's domain. Here's a sample from the log:

    2014-12-05 05:10:45: - The retina file '/home3/username/public_html/widget/widget/static/riding-a-bike@2x.jpg' cannot be found.

    The file it should be referencing is at this path:

    I can create a duplicate folder of images at the incorrect path, but that seems like an ugly workaround.

    Help please?

  3. Jordy Meow
    Plugin Author

    Posted 1 year ago #


    It seems you are the only one with this specific issue so my guess is there is something "special" about your install. The images uploaded through the Media Manager go into /static? How did you define this folder for the uploaded images? Did you redefine the UPLOADS constant?

    I checked this article:

    The define of the UPLOADS constant should also be done before "require_once(ABSPATH.’wp-settings.php’);".

    The plugin relies on those constant so if they are wrong, the retina files will be wrong too.

    Alternatively, do you have dev skills on your side to track down the specific problem? Or a developer that could help you?

  4. Jordy Meow
    Plugin Author

    Posted 1 year ago #

    By the way, someone had a similar issue and found out how to resolve it. Can you check this thread?


    I am planning a new release sometimes this month and this change will be definitely included. If that would work for you too, then it would be awesome :)

  5. homebysix
    Posted 1 year ago #

    Thanks for your response!

    Sorry, I should have clarified — I'm not uploading the images through the WordPress interface. I'm simply placing the image files and their @2x equivalents in the "static" folder (using FTP), and the WP Retina 2x plugin automatically detects and serves the appropriate image. This works fine for my other WordPress sites, even the ones using the WP Retina 2x plugin.

    The "special" thing about this particular setup is that I have one WP site nested within another. For example, the main site is at http://www.pretendco.com and the subsite is at http://www.pretendco.com/subsite.

    The @2x (retina quality) images work fine on the main site, where they are located at http://www.pretendco.com/static/image@2x.jpg. They don't work on the subsite, where they are located at http://www.pretendco.com/subsite/static/image@2x.jpg.

    Both the main site and the subsite images are using standard absolute paths:
    <img src="/static/image.jpg"> and <img src="/subsite/static/image.jpg">
    And the regular non-retina images are displaying correctly on both the main site and the subsite. However, the retina images on the subsite are not being displayed, because the WP Retina 2x plugin is looking for them in the wrong place: /static/* instead of /subsite/static/*.

    I'm reasonably savvy but not a full time dev. It feels like a bug, but I'm not sure how to go about isolating it further. Any pointers?

  6. homebysix
    Posted 1 year ago #

    This is still occurring on WordPress 4.1.

    I have worked around this issue by creating a symbolic link from the "correct" image path URL to the "incorrect" image path URL. The result of this is that the non-retina images load from /subsite/static/riding-a-bike.jpg and the retina images load from the symbolic path /subsite/subsite/static/riding-a-bike@2x.jpg.

    Here are the shell commands I used to do the workaround, in case they are useful to others:

    # Navigate to your subsite directory
    cd /path/to/public_html/subsite
    # Create a symbolic link with the same name as your subsite's directory
    ln -s . subsite

    The root issue is not technically resolved, but I'm marking this thread as resolved since this workaround will work indefinitely.

  7. Jordy Meow
    Plugin Author

    Posted 1 year ago #

    The problem will always happen unfortunately because the plugin is made to work with images you upload through the system. If you create a static folder (which is not the 'upload' folder) the plugin doesn't know where are the files exactly... even though it could try to guess through the original image path, it would be really a guess and in the code I prefer to avoid any guess and stick to global var or the WordPress API to clearly identify identify the path for the retina images.

    To be honest, I think the symbolic link is the right thing to do: you already using a trick around the system by creating your own static directory for the images and upload them by yourself (which is fine) and the symbolic link will help all the plugins and the system to get a reference to it. I think your solution is much cleaner than adding an option in the plugin or have some "guessing" code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Retina 2x
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic