Support » Plugin: WP Retina 2x » Plugin is looking for @2x image at the relative path instead of absolute

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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:
    /home3/username/public_html/widget/static/riding-a-bike@2x.jpg

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

    Help please?

    Plugin Author Jordy Meow

    (@tigroumeow)

    Hello,

    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:
    http://premium.wpmudev.org/blog/change-default-wordpress-uploads-folder/

    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?

    Plugin Author Jordy Meow

    (@tigroumeow)

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

    https://wordpress.org/support/topic/path-incorrect-as-custom-uploads-directory-location-with-bedrock?replies=3#post-6114319

    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 🙂

    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?

    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.

    Plugin Author Jordy Meow

    (@tigroumeow)

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Plugin is looking for @2x image at the relative path instead of absolute’ is closed to new replies.