Support » Fixing WordPress » Media files: how to change url to absolute path?

  • Resolved SchweizerSchoggi

    (@schweizerschoggi)


    Good morning
    In our website the media library shows the relative path to the images.
    For the common use in a post that’s fine. But I cannot use one of the images as a default social mideia image in Yoast, because there it needs to be an absolute path and the library does not provide this.

    Any idea what I can set or check?

    In WP Admin => Settings => General => WordPress Address (URL) and as well as
    in WP Admin => Settings => General => Site Address (URL)
    I do see the absolute url: http://subdomain.domain.com

    so I would expect that it should work, but it soes not

Viewing 13 replies - 1 through 13 (of 13 total)
  • Good morning,
    I do understand that you prefer to find a solution for this issue.
    But if you only need 1 image, wouldn’t it be quicker to manually convert that relative url to the absolute one?

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    Well… for sure if that is possible?? Can you tell me how to do this?
    Whereever I check the settings for the image, url is always readonly. But yeah, maybe I just don’t know where to have a look.

    Maybe there is miscommunication.
    Yes, you are right, when you open an image in the media library, the url is readonly. You can’t edit it (example).
    What I meant is if you take your domain url (e.g. https://subdomain.domain.com) and add a relative url of your image to it (e.g. /some/relative/path.jpg), you will get the absolute url. E.g. https://subdomain.domain.com/some/relative/path.jpg
    So, if you need to get an absolute URL for 1 image only, it would be quicker than trying to make WordPress to use absolute URLs everywhere.

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    The problem is that I need an image for social media activities (og default image, set via Yoast plugin).
    To set this image I can select it from the WP media libtrary.
    But it’s not possible to edit the url somewhere afterwards and the plugin does not allow relative paths 🙁

    Hi @schweizerschoggi

    In @antonvlasenko’s screenshot above – https://cloudup.com/c9T0MpZDfTi the pointed link is an absolute url that you can copy and paste it to set as social thumbnail. Why do you need to edit the url at all?

    @ashfame

    But it’s not possible to edit the url somewhere afterwards and the plugin does not allow relative paths

    As far as I understand the issue is that @schweizerschoggi can’t change the url afterwards and media library only allows to use relative URLs in conjunction with Yoast plugin.

    @antonvlasenko I am unable to follow. When I go to social tab to pick a media image to be used for FB/Twitter, I can simply choose one from my media library prompt and it displays there. Then in HTML I can see jetpack’s (photon?) CDN url which obviously has an absolute url.

    @ashfame

    When I go to social tab to pick a media image to be used for FB/Twitter, I can simply choose one from my media library prompt and it displays there.

    That was my thinking as well. If a user selects an image in the media library, WordPress has to display it using the absolute url.

    @schweizerschoggi I’ve been trying to debug the source code to understand how it could happen (I mean relative urls), and I can’t find any clues.
    IMO it would help if you posted screenshots showing the relative URLs or maybe record a screencast.

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    @antonvlasenko and @ashfame

    As far as I understand the issue is that @schweizerschoggi can’t change the url afterwards and media library only allows to use relative URLs in conjunction with Yoast plugin.

    Exactly that’s the case here.
    My general WP settings are set to absolute urls, but via media library I am only getting relative urls.

    See screenshots:
    Capture 1
    Capture 2
    Capture 3
    Capture 4

    • This reply was modified 2 months, 4 weeks ago by SchweizerSchoggi. Reason: typo

    @schweizerschoggi I see, we were trying with the same image chooser on the post/page edit screen. I would classify this as a bug in Yoast SEO and this needs to be reported to them so that they can fix it. Moreover, this is supposed to only act as a fallback so will be used only for posts/pages which don’t have an image set for them.

    I do have an old plugin which works fine and tries to pick first image as per context and set that. You can try to run it along with it temporarily or along with it, however you see it fit.

    https://wordpress.org/plugins/facebook-like-thumbnail/

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    Yes, I have reported it already, but they say that they can’t fix it, because the image needs to come with an absolute url. So well….. deinitily looks like I have to look for another solution here.

    Your plugin sounds promising on the first glance. Does it support Twitter as well or is it Facebook-specific?

    I checked default behavior on my installs and within media uploader, the file url always show up as absolute urls. So there is something specific to your install which makes it relative. This is why Yoast team said they can’t fix it because absolute urls function reliably.

    Are you using a particular plugin to use relative urls for images? If you don’t know, you should try the site with all plugins disabled to see (might have to do with a new image upload). This could also be a part of your theme, so you will have to try switching to the default theme as well.

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    I guess you’re right, it might be a plugin that is switching the urls from absolute to relative. Or the theme itself. As I don’t have a test environemt atm and only the live server I won’t switch any themes or deactivate all plugins.

    I am using another plugin now (“Open Graph and Twitter Card Tags”) which works for my case. That’s not the perfect solution I was hoping for but yes, it does work and I can close the case here.

    Anyway, thank you guys for your ideas and time. Have a wonderful summer
    Schoggi

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.